![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 09:56 AM. |