|
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 |
|