×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

feature extrusion API

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

RE: feature extrusion API

Is it possible for your place of business to send you to a VB class?

RE: feature extrusion API

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.

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.
http://www.EsoxRepublic.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources