![]() |
【转帖】shaft programming
shaft programming.......
i have program 2 shaft with different diameter.............. when i insert data for example 6m to the shaft1 the shaft is show the correct diameter.........but the problem is the 2nd diameter is not show the 6m diameter.....the shaft will show 6.8m.......here is my code.... private sub cmdpapar_click() set swapp = application.sldworks set part = swapp.activedoc set selmgr = part.selectionmanager swapp.activedoc.activeview.framestate = 1 part.clearselection2 true dim skcircle as object set skcircle = part.sketchmanager.createcircle(0, 0, 0, txt1.text, 5.605184485944e-04, 0) part.clearselection2 true boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0) part.featuremanager.featureextrusion2 true, false, false, 0, 0, txt2.text, txt2.text, false, false, false, false, 0.01745329251994, 0.01745329251994, false, false, false, false, 1, 1, 1, 0, 0, false part.selectionmanager.enablecontourselection = 0 part.clearselection2 true set swapp = application.sldworks set part = swapp.activedoc set selmgr = part.selectionmanager swapp.activedoc.activeview.framestate = 1 set skcircle = part.sketchmanager.createcircle(0, 0, 0, txt3.text, -1.244946376429, 0) part.clearselection2 true boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0) part.featuremanager.featureextrusion true, false, true, 0, 0, txt4.text, txt4.text, false, false, false, false, 0.01745329251994, 0.01745329251994, false, false, false, false, 1, 1, 1 part.selectionmanager.enablecontourselection = 0 part.clearselection2 true end sub i'm not exactly sure what your use of this is, but i have changed your code a bit and will try to explain how this works. option explicit sub main() dim swapp as sldworks.sldworks dim part as sldworks.modeldoc2 dim sketchmanager as sldworks.sketchmanager dim selmgr as sldworks.selectionmgr dim boolstatus as boolean set swapp = application.sldworks set part = swapp.activedoc set sketchmanager = part.sketchmanager set selmgr = part.selectionmanager swapp.activedoc.activeview.framestate = 1 part.clearselection2 true dim skcircle as object '** creates a circle sketch at the x,y,z location 0, 0, 0. the radius of the circle, in inches, is txtradius1.text :: note the other x,y,z values are 0 set skcircle = sketchmanager.createcircle(0, 0, 0, (txtradius1.text / 39.3700787) / 2, 0, 0) part.clearselection2 true '** the arc is selected and then subsequently constrained as fixed for the extrusions boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0) part.sketchaddconstraints "sgfixed" '** extrudes the circle in one direction, towards the user, of length equal to txtextrustionlength1.text part.featuremanager.featureextrusion2 true, false, false, 0, 0, txtextrusionlength1.text / 37.3700787, 0, false, false, false, false, 0, 0, false, false, false, false, 1, 1, 1, 0, 0, false part.selectionmanager.enablecontourselection = 0 part.clearselection2 true '** creates a circle sketch at the x,y,z location 0, 0, 0. the radius of the circle, in inches, is txtradius2.text :: note the other x,y,z values are 0 set skcircle = sketchmanager.createcircle(0, 0, 0, (txtradius2.text / 39.3700787) / 2, 0, 0) part.clearselection2 true '** the arc is selected and then subsequently constrained as fixed for the extrusions boolstatus = part.extension.selectbyid2("arc1", "sketchsegment", 0, 0, 0, false, 0, nothing, 0) part.sketchaddconstraints "sgfixed" '** extrudes the circle in one direction, away from the user, of length equal to txtextrustionlength2.text part.featuremanager.featureextrusion2 true, false, true, 0, 0, txtextrusionlength2.text / 37.3700787, 0, false, false, false, false, 0, 0, false, false, false, false, 1, 1, 1, 0, 0, false part.selectionmanager.enablecontourselection = 0 end sub the reason it was returning two different values before, was the conflicting x,y,z size of the created circles. referencing the following areas in the help document may also help you. sketchmanager::createcircle featuremanager::featureextrusion2 these examples will tell you what each of the true/false as well as numeric values mean in each of those lines of code. edited: 10/14/2008 at 11:09 am by blake dahle quick |
所有的时间均为北京时间。 现在的时间是 09:34 PM. |