几何尺寸与公差论坛

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

【转帖】edit all parts of an assembly

[复制链接]
发表于 2009-4-12 20:46:11 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 10:35 , Processed in 0.035301 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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