几何尺寸与公差论坛

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

【转帖】raverse assembly - add custom property

[复制链接]
发表于 2009-4-13 15:02:38 | 显示全部楼层 |阅读模式
traverse assembly - add custom property
i am trying to write what i thought would be an easy api script. all i want it to do is to traverse all parts in an assembly and add some custom properties to them. i have managed to get it done with one method, but that way flashes each part across teh screen. i would prefer if it did not do that. i have written this, and it traverses the assembly and can debug print, each child. but i cannot get it to add the property.
what am i missing. thank you in advance for you help and time.
__________
sub main()
dim swapp           as sldworks.sldworks
dim swmodel         as sldworks.modeldoc2
dim refmodel        as sldworks.modeldoc2
dim custpm          as sldworks.custompropertymanager
dim nerrors         as long
dim nwarnings       as long
dim childname       as string
dim addprop         as string
dim vchild          as variant
dim vparent         as variant
set swapp = application.sldworks
set swmodel = swapp.activedoc
vparent = swmodel.getpathname
debug.print vparent
vchild = swapp.getdocumentdependencies2(vparent, true, false, false)
for i = 1 to (ubound(vchild)) step 2
   
debug.print vchild(i)
set refmodel = swapp.opendoc6(vchild(i), swdocpart, swopendocoptions_silent, "", nerrors, nwarnings)
set custpm = refmodel.extension.custompropertymanager("")
addprop = custpm.add2("my test", swcustominfotext, "blah")
next i
end sub
check out our whitepaper library.
nevermind...i went and had lunch and when i came back. the code seems to work just fine.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-22 13:04 , Processed in 0.034908 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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