![]() |
【转帖】rename in feature manager tree
rename in feature manager tree
the macro below(macro 1) works fine. the object of the macro is to extrude a surface and rename the feature in the feature manager tree accordingly.the pre-condition should be that a line has to be selected before running the macro. macro2 works pretty much the same as macro1. the problem arises when macro 2 is run accidently without selecting a sketch.macro 2 renames the sketch of the previous surface to "electrode surface".i require both these macros to work only if a sketch line is selected. macro1 dim swapp as object dim part as object dim selmgr as object dim boolstatus as boolean dim longstatus as long, longwarnings as long dim feature as object sub main() set swapp = application.sldworks set part = swapp.activedoc set selmgr = part.selectionmanager boolstatus = part.extension.selectbyid2("line4", "sketchsegment", -0.01345668175817, 0.03285693360425, 0, false, 0, nothing, 0) part.clearselection2 true boolstatus = part.extension.selectbyid2("line4", "sketchsegment", -0.01345668175817, 0.03285693360425, 0, false, 0, nothing, 0) part.featureextrurefsurface2 true, false, false, 0, 0, 0.005, 0.0025, false, false, false, false, 0.02617993877992, 0.02617993877992, false, false, false, false part.selectionmanager.enablecontourselection = 0 part.featurebypositionreverse(0).name = "wire surface" end sub macro2 dim swapp as object dim part as object dim selmgr as object dim boolstatus as boolean dim longstatus as long, longwarnings as long dim feature as object sub main() set swapp = application.sldworks set part = swapp.activedoc set selmgr = part.selectionmanager boolstatus = part.extension.selectbyid2("line1", "sketchsegment", 0.02949422013878, 0.01517958600207, -0.0225, false, 0, nothing, 0) part.clearselection2 true boolstatus = part.extension.selectbyid2("line1", "sketchsegment", 0.02949422013878, 0.01517958600207, -0.0225, false, 0, nothing, 0) part.featureextrurefsurface2 true, false, true, 0, 0, 0.005, 0.005, false, false, false, false, 0.02617993877992, 0.02617993877992, false, false, false, false part.selectionmanager.enablecontourselection = 0 part.featurebypositionreverse(0).name = "surefirst surface" end sub feroz mahomed windows xp professional sp2 sworks 2009 sp2 nvidia quadro fx1500 hi, what you have forces the selection of a specific line regardless of pre-selection. you want to test for pre-selection before trying to extrude the surface. you could also validate the selection to see if it is what is needed. ------sample macro------ dim swapp as sldworks.sldworks dim part as object dim selmgr as sldworks.selectionmgr dim boolstatus as boolean dim longstatus as long, longwarnings as long dim feature as object sub main() set swapp = application.sldworks set part = swapp.activedoc set selmgr = part.selectionmanager if selmgr.getselectedobjectcount = 0 then msgbox "nothing is selected." exit sub end if part.featureextrurefsurface2 true, false, false, 0, 0, 0.00254, 0.00254, false, false, false, false, 0.01745329251994, 0.01745329251994, false, false, false, false part.selectionmanager.enablecontourselection = 0 part.selectedfeatureproperties 0, 0, 0, 0, 0, 0, 0, 1, 0, "new name of feature here" part.clearselection2 true end sub hi scott, the macro works fine now. thank you for the speedy response. i have another macro that is used to rename a sketch in the feature manager tree.is it possible to have the user select a new name from a form/drop down or listbox?i currently have 8 macros to rename 8 different sketches. feroz mahomed windows xp professional sp2 sworks 2009 sp2 nvidia quadro fx1500 quick |
所有的时间均为北京时间。 现在的时间是 01:44 PM. |