|
edit all parts of an assembly
hello!
how's it things?
i have created an assembly and i want to edit all the components. i have tried this one:
sub edit()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
set swapp = createobject("sldworks.application")
set swmodel = swapp.activedoc
dim a as boolean
a = swmodel.extension.selectbyid2("box@assembly1", "component", 0, 0, 0, false, 0, nothing, 0) 'box is a component of assembly1
swmodel.editpart
'''''''''
swmodel.clearselection2 true
swmodel.editrebuild3
end sub
but with this code i have to known all components' names. is it possible to edit each component without knowing its names?
thank you for your help!
by using
retval = sldworks.getdocumentdependencies2 ( document, traverseflag, searchflag, addreadonlyinfo )
you can store the name of all parts in your assembly and acess them however you like.
i want to have the assembly open and i have to see how the componentes are edit. so, i can´t use your code. sorry, i will explain better before the next time.
what about assemblydoc::getcomponents? that will return an array of all the component2 objects in assembly. you can get the component's name, or select the component directly with component2::select3.
i'll get you eh steve, if it's the last thing i dooooo!
i tried in your way but a component can´t edit. i look the api help up an only i can edit parts.
you will still need to use editpart after selecting the component. as i said, after you use assemblydoc::getcomponents you will have an array of component2 objects. each component2 object has a name you can use with selectbyid before using editcomponent. or you can use each component2's select3 method to select the component prior to editpart.
i'll get you eh steve, if it's the last thing i dooooo!
i'm gonna use component2's select3 because with selectbyid i need the component full name with the number (like box-1) and the assembly name. but to use *retval = component2.select3 ( append, data) what i have to write in data? and what kind of type is it? i have looked the api up but i have not understood very well.
thanks again!
you can use nothing for data or you can create a selectdata object
so it can be :
comp.select3(true, nothing)
or
dim swseldata as sldworks.selectdata
.
.
.
set swseldata = selmgr.createselectdata
retval = comp.select3(true,swseldata)
in this world i am nobody...
and nobody is perfect ;) !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
great stavros!
i think i'm gonna use comp.select3(true, nothing).
thank you very much!
quick |
|