feature extrusion API
feature extrusion API
(OP)
I have this bit of code that I'm trying to modify to do an extrusion of a rectangular sketch with the dims that I specify. I've found in the API help where it tells me the definitions of the values I need to imput but I still can't get it to do a midplane extrusion with a value I specify.
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = CreateObject("SldWorks.Application")
'swApp.ActiveDoc.ActiveView.FrameLeft = 0
'swApp.ActiveDoc.ActiveView.FrameTop = 0
'swApp.ActiveDoc.ActiveView.FrameState = 1
'swApp.ActiveDoc.ActiveView.FrameState = 1
Set Part = swApp.NewPart()
Part.InsertSketch
Part.SketchRectangle 0, 0, 0, 0.07748542510121, -0.04675519568151, 0, 1
Part.ClearSelection
Part.SelectByID "Line1", "SKETCHSEGMENT", 0.03977962213225, 0, 0
Part.AddDimension 0.0397796, 0.0116888, 0
Part.ClearSelection
Part.SelectByID "Line4", "SKETCHSEGMENT", 0.07748542510121, -0.02337759784076, 0
Part.AddDimension 0.0974695, -0.0233776, 0
Part.ClearSelection
Part.SelectByID "D1@Sketch1@Part1.SLDPRT", "DIMENSION", 0, 0, 0
Part.SetPickMode
Part.ClearSelection
Part.SelectByID "D2@Sketch1@Part1.SLDPRT", "DIMENSION", 0.09822361673414, -0.02413171390013, 0
Part.Parameter("D2@Sketch1").SystemValue = 0
Part.SelectByID "D1@Sketch1@Part1.SLDPRT", "DIMENSION", 0.03902550607287, 0.01319703103914, 0
Part.Parameter("D1@Sketch1").SystemValue = 0
Part.FeatureExtrusion3 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = CreateObject("SldWorks.Application")
'swApp.ActiveDoc.ActiveView.FrameLeft = 0
'swApp.ActiveDoc.ActiveView.FrameTop = 0
'swApp.ActiveDoc.ActiveView.FrameState = 1
'swApp.ActiveDoc.ActiveView.FrameState = 1
Set Part = swApp.NewPart()
Part.InsertSketch
Part.SketchRectangle 0, 0, 0, 0.07748542510121, -0.04675519568151, 0, 1
Part.ClearSelection
Part.SelectByID "Line1", "SKETCHSEGMENT", 0.03977962213225, 0, 0
Part.AddDimension 0.0397796, 0.0116888, 0
Part.ClearSelection
Part.SelectByID "Line4", "SKETCHSEGMENT", 0.07748542510121, -0.02337759784076, 0
Part.AddDimension 0.0974695, -0.0233776, 0
Part.ClearSelection
Part.SelectByID "D1@Sketch1@Part1.SLDPRT", "DIMENSION", 0, 0, 0
Part.SetPickMode
Part.ClearSelection
Part.SelectByID "D2@Sketch1@Part1.SLDPRT", "DIMENSION", 0.09822361673414, -0.02413171390013, 0
Part.Parameter("D2@Sketch1").SystemValue = 0
Part.SelectByID "D1@Sketch1@Part1.SLDPRT", "DIMENSION", 0.03902550607287, 0.01319703103914, 0
Part.Parameter("D1@Sketch1").SystemValue = 0
Part.FeatureExtrusion3 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1






RE: feature extrusion API
RE: feature extrusion API
Use the macro code as a starting-off point to familiarize yourself with the API calls involved. Look in the API help to see the structure of the calls.
If you need to write a macro that handles selections, you need to get familiar with the Selection Manager object, and how it handles selections.
Finally, do take some time to learn VB6 first, in a context outside of macro/API programming. This will help you sort out recorded macros and the API help. There are many great books available to start you on your way. Your best bet is to stop by a bookstore and find one you like. I highly recommend the "Visual" series of books. These books bear the slogan "Read less. Learn more." on their covers.
http://www.EsoxRepublic.com