Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

feature extrusion API 1

Status
Not open for further replies.

Yogibear

Mechanical
Sep 5, 2002
107
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
 
Replies continue below

Recommended for you

Is it possible for your place of business to send you to a VB class?
 
This code is apparently the direct result of reording a macro. Macro recordings aren't always the best way to start writing, as they add some commands that don't need to be in the code. Macros tend to call functions as if they were subs, forgoing the return variables. Also, macros record entity selections explicitly, making it somewhat difficult to edit them for future use if selections are involved.

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.

[bat]There are two types of people in the world: the kind that believe that people can be categorized into one of two groups and the kind that don't.[bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor