几何尺寸与公差论坛

 找回密码
 注册
查看: 816|回复: 0

【转帖】how do i reference a configuration specific property

[复制链接]
发表于 2009-4-13 11:51:16 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 22:59 , Processed in 0.037044 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表