几何尺寸与公差论坛

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

【转帖】rying to get file properties of the root component in a view

[复制链接]
发表于 2009-4-13 15:04:37 | 显示全部楼层 |阅读模式
trying to get file properties of the root component in a view
hello everyone!
here is a problem that i have been working on all day. i hope someone can help me.
given a selected view in a drawing, how can i get to the file properties of the assembly in that view? on the surface it seems pretty easy, there are lots of examples of how to get to the children components of an assembly...but i want the assembly itself. swcomp.getmodeldoc always returns nothing for the root?
please see my example below:
sub main()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swdraw as sldworks.drawingdoc
dim swselmgr as sldworks.selectionmgr
dim swview as sldworks.view
dim swdrawcomp as sldworks.drawingcomponent
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swdraw = swmodel
set swselmgr = swmodel.selectionmanager
set swview = swselmgr.getselectedobject5(1)
set swdrawcomp = swview.rootdrawingcomponent
' returns empty strings for root component...why?
debug.print swdrawcomp.component.name2
dim objmodel as modeldoc2
set swcomp = swdrawcomp.component
set objmodel = swcomp.getmodeldoc 'why always returns nothing for the root?
debug.print objmodel.custominfo2("", "description")
end sub
what in the world am i missing? many thanks in advance...
jeff sweeney, cswp
sw user since '96
jeff,
not familiar with drawingcomponent object. i have used
dim assyname as string
assyname = swview.getreferencedmodelname
set objmodel = swapp.opendoc6 (assyname, swdocassembly, swopendocoptions_silent, "", nerrors, nwarnings)
wayne matus
texas engineering systems
thanks wayne, that is an interesting approach to the problem, and i am sure it would work. certainly there is a way to do it without opening the document though? it is already in memory!
jeff sweeney, cswp
sw user since '96
answer jeff,
i just found something in the api help that should work.
set objmodel = swview.referenceddocument
wayne matus
texas engineering systems
perfect! i knew i had to be overlooking something. thanks!
jeff sweeney, cswp
sw user since '96
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-22 13:09 , Processed in 0.035446 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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