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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   【转帖】api .name2 just changes in feature tree (http://www.dimcax.com/hust/showthread.php?t=5066)

yang686526 2009-04-13 08:55 AM

【转帖】api .name2 just changes in feature tree
 
api: .name2 just changes in feature tree
i have the following code that i wrote to rename the components in an assembly. when run the code the names change on the feature tree. it appears that the names are not really changing because you can rebuild and they revert back to old names. any ideas what i am doing wrong?
set swapp = createobject("sldworks.application")
swmodel.custominfo2("", "panelnumber") = panelid
boldsetting = swapp.getuserpreferencetoggle_(swextrefupdatecompnames)
'debug.print boldsetting
swapp.setuserpreferencetoggle swextrefupdatecompnames, false
vchildcomparr = swcomp.getchildren
for i = 0 to ubound(vchildcomparr)
set swchildcomp = vchildcomparr(i)
curname = swchildcomp.name2
newname = buildnewname(curname, panelid)
'debug.print newname
bret = swchildcomp.select(false)
'debug.print bret
swchildcomp.name2 = newname
'debug.print swchildcomp.name2
swmodel.custominfo2("", "panelnumber") = panelid
next i
swapp.setuserpreferencetoggle swextrefupdatecompnames,_ boldsetting

posting in the eng-tips forums is a member-only feature.


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