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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 08:53 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】feature folders

feature folders
have existing folder in the feature tree named "mbi"
how do i move an selected component into the "mbi" folder with the api functions?
use featuremanager::movetofolder for solid bodies. i am still searching for the way for components
hey sam,
have a look at
assemblydoc::reordercomponents
if you are having trouble with it reply here and i'll try to give you more info.
cheers,
--stav.
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
originally posted by: stavros antoniou
have a look at
assemblydoc::reordercomponents
if you are having trouble with it reply here and i'll try to give you more info.
hello,
i tried to use this method, but doesn't work ...
i insert a new folder and rename it - ok, it works
i get all components of the assembly in an array - ok, it works
i filter the components, which i want move to the folder in a new array - ok, it works
now i call assemblydoc::reordercomponents with the parameters: new array of pointers of filtered components, pointer of new folder and where=swreordercomponents_lastinfolder
but it doesn't work! the return value is always false! and no component is moved to the folder! why? what's wrong?
all the filtered components are one behind the other in the featuremanager-tree - whithout a gap.
it doesn't work also with only one component to move!
ok - i know i can also select the components before inserting the new folder - that works - the selected components are moved in the new created folder.
but i need to move components into an existing folder.
can anybody help?
ok here we go,
i will asssume that the folder already exists and its name is "myfolder", i will also assume that you have selected all the compoents you want to move in the folder. the macro below does just that.
now if you want to also create the folder use this function instead insertfeaturetreefolder2
the function above inserts the preselected components in the newly created folder.
if you have further issues let me know.
cheers,
--stav.
option explicit
dim swapp as sldworks.sldworks
dim modeldoc as sldworks.modeldoc2
dim asmdoc as sldworks.assemblydoc
dim selmgr as sldworks.selectionmgr
dim myfeature as sldworks.feature
dim componentstomove() as sldworks.component2
dim i as integer, count as integer
dim boolstatus as boolean
sub main()
set swapp = application.sldworks
set modeldoc = swapp.activedoc
set asmdoc = modeldoc
set selmgr = modeldoc.selectionmanager
count = selmgr.getselectedobjectcount2(0)
redim componentstomove(count - 1)
for i = 0 to count - 1
set componentstomove(i) = selmgr.getselectedobjectscomponent3(i + 1, 0)
next
set myfeature = asmdoc.featurebyname("myfolder")
modeldoc.clearselection2 true
boolstatus = asmdoc.reordercomponents(componentstomove, myfeature, swreordercomponentswhere_e.swreordercomponents_lastinfolder)
end sub
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
hello and thank you,
now my macro also works!
the problem was: i wrote it in late binding!
the methode assemblydoc.reordercomponents works only with early binding and the object has to be assemblydoc, modeldoc2 as object is not enough!
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多