几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 11:51 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how do i reference a configuration specific property

how do i reference a configuration specific property?
i have a macro i wrote a year or two ago to create and save a pdf in a released drawings folder with the rev level in the pdf file name. we recently started using a m2m module add-on that allows sw to interface with m2m. unfortunately, the m2m-sw shared property text is done using a specific configuration and not just the general custom properties tab. does anyone know how i can modify my code to look at the configuration specific peropty for "rev" instead of the general tab?
appreciate any help!
here's my code:
sub main()
'get solidworks object
set swapp = application.sldworks
'get active document object
set swdoc = swapp.activedoc
'add check to see that active docuement is drawing
'get first view in drawing (always sheet format)
set swdrwview = swdoc.getfirstview
'get first drawing view
set swdrwview = swdrwview.getnextview
'get object of document in view (part or assembly)
set swrefdoc = swdrwview.referenceddocument
'get rev custom property
revcustomproperty = swrefdoc.custominfo2("", "rev")
'get name of document
name = swdoc.gettitle()
'determine just the filename without the file extension (xxxx-xxx)
name = left$(name, 9)
'determine released 2-digit folder
releasedfolder = left$(name, 2)
'save as a pdf with rev number in the corresponding released folder
swdoc.saveas2 "g:\shares\released_drawings\" & releasedfolder & "\" & name & " rev " & revcustomproperty & ".pdf", 0, true, false
'send confirmation message to user
msgbox ("g:\shares\released_drawings\" & releasedfolder & "\" & name & " rev " & revcustomproperty & ".pdf has been saved.")
end sub
revcustomproperty = swrefdoc.custominfo2("", "rev")
the first argument where you have a null string "" is for the configuration name. null string is for the global property. to get config-specific name, use the config name instead of null string.
understand what you are saying... but i'm not sure it is that simple. the m2m module (made 2 manage) creates configuration-specific property text, but does not actually create a configuration. so (1) i'm not sure what the configuration name would be, and (2) i think this name migth change for every part.
see screenshot image for reference.
any other ideas? appreciate your suggestion though!
click for full image
in the screenshot example you simply use the name of the current configuration. for example:
cp = swmodel.custominfo2("default", "m2mitemid")
thanks luke, that works for a default config that m2m creates.
i just used the following line instead to capture the rev:
cp = swmodel.custominfo2("default", "rev")
now, would there be a way to capture the name of the configuration for the part/assy that is used in the drawing? i imagine i would need to set a variable to look at the referenced document's configuration name. then i could always grab that configuration's rev in case the configuration has a name other than default. i figure there must be a way, i just do not know what the callout would be to grab a refdoc's config name.
just get any view of the drawing and call view::referencedconfiguration
originally posted by: luke malpass
just get any view of the drawing and call view::referencedconfiguration
thanks luke.
i tried what you said a few different ways and it does not appear to be happy with the code. here is what i have currently, it fails when i try to use the .referencedconfiguration callout. am i missing something simple? thanks again.
sub main()
'get solidworks object
set swapp = application.sldworks
'get active document object
set swdoc = swapp.activedoc
'add check to see that active docuement is drawing
'get first view in drawing (always sheet format)
set swdrwview = swdoc.getfirstview
'get first drawing view
set swdrwview = swdrwview.getnextview
'get object of document in view (part or assembly)
set swrefdoc = swdrwview.referenceddocument
'get cofiguration name of object in view
set configname = swrefdoc.referencedconfiguration
'get rev custom property of active configuration
revcustomproperty = swrefdoc.custominfo2(configname, "rev")
'get name of document
name = swdoc.gettitle()
'determine just the filename without the file extension (xxxx-xxx)
name = left$(name, 9)
'determine released 2-digit folder
releasedfolder = left$(name, 2)
'save as a pdf with rev number in the corresponding released folder
swdoc.saveas2 "g:\shares\released_drawings\" & releasedfolder & "\" & name & " rev " & revcustomproperty & ".pdf", 0, true, false
'send confirmation message to user
msgbox ("g:\shares\released_drawings\" & releasedfolder & "\" & name & " rev " & revcustomproperty & ".pdf has been saved.")
end sub
edited: 06/25/2008 at 09:08 am by scott wheeler
configname = swdrwview.referencedconfiguration
remember i said its the view method, not the model.
originally posted by: luke malpass
set configname = swdrwview.referencedconfiguration
remember i said its the view method, not the model.
doh! i should have caught that..... thank you.
hmmm.... still failing on "set configname = swdrwview.referencedconfiguration".
is the 'referencedconfiguration' correct? maybe it's referencedconfig or something similar? i set configname as an object, so that should not be an issue either. not sure what else i might be doing wrong.
remove the set, keyword, it in not needed as you are returning a string
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】function to control the bom quantity custom property setting yang686526 SolidWorks二次开发 0 2009-04-13 10:59 AM
【转帖】changing configuration names using document manager yang686526 SolidWorks二次开发 0 2009-04-13 09:40 AM
【转帖】add custom property at specific location yang686526 SolidWorks二次开发 0 2009-04-13 08:41 AM
【转帖】configuration id other than configuration name yang686526 SolidWorks二次开发 0 2009-04-12 08:29 PM


所有的时间均为北京时间。 现在的时间是 01:55 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多