VBA: Extrude Upto Vertex

Discussion in 'SolidWorks' started by Corey Scheich, Oct 24, 2003.

  1. Ok I am trying to automate extrude up to vertex. I recorded doing this and
    even the recorded macro doesn't work when played back under the same
    circumstances.

    I have tried two methods.

    I have the model rebuilt before selecting both the sketch and the vertex.
    (the vertex I am using is a sketch Point.)

    AsModelDoc.FeatureBoss2 True, False, True, 3, 0, 0, 0, False, False, False,
    False, 0, 0, False, False, False, False

    Set ExtrusionFeat = FeatMan.FeatureExtrusion(True, False, False, 3, 0, 0, 0,
    False, False, False, False, 0, 0, False, False, False, False, False, True,
    True)

    Thank you,

    Corey Scheich
     
    Corey Scheich, Oct 24, 2003
    #1
  2. let me see the whole macro
     
    Sean Phillips, Oct 25, 2003
    #2
  3. Here is a simplified example that works the same to
    it is assumed with this example that you have a sketch
    with one closed contour selected first from the tree,
    then the second selection (using CTRL) is a point.
    These are selected before running the macro. I am
    using SW2003 SP 4.1 on XP

    Dim swApp As SldWorks.SldWorks
    Dim Part As SldWorks.ModelDoc2
    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
    Dim FeatMan As SldWorks.FeatureManager
    Dim ThisPoint As SldWorks.SketchPoint
    Dim ThisLine As SldWorks.SketchLine
    Dim feat As SldWorks.Feature
    Dim SelMan As SldWorks.SelectionMgr
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    Set SelMan = Part.SelectionManager
    Set FeatMan = Part.FeatureManager
    Set feat = SelMan.GetSelectedObject4(1)
    Set ThisPoint = SelMan.GetSelectedObject4(2)

    Part.ClearSelection

    feat.Select2 False, 0
    ThisPoint.Select3 True, 1, Nothing

    FeatMan.FeatureExtrusion True, False, False, 3, 0, 0.00254, 0.00254, False,
    False, False, False, 0.01745329251994, 0.01745329251994, False, False,
    False, False, 1, 1, 1

    Part.SelectionManager.EnableContourSelection = 0
    Part.ClearSelection

    End Sub

    I appreciate the help

    Thank you,
    Corey Scheich
     
    Corey Scheich, Oct 27, 2003
    #3
  4. Just a side note: Extruding up to Body works great, even the recorded macro
    runs. So I don't understand why going to a vertex doesn't quite work.
     
    Corey Scheich, Oct 27, 2003
    #4
  5. It is actually part of a much longer macro. It will be able to create a
    "sweep" without giving the "Sweep intersected itself" error.

    Corey



    Hello Corey-
     
    Corey Scheich, Oct 27, 2003
    #5
  6. here this works now.

    select a sketch and a vertex or sketchpoint.
    you must list it as a variant because you dont know what the user has
    selected.
    you should do some error checking if it is upto the user to make the
    selections.


    Dim swApp As SldWorks.SldWorks
    Dim Part As SldWorks.ModelDoc2
    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
    Dim FeatMan As SldWorks.FeatureManager
    Dim ThisPoint As Variant
    Dim ThisLine As SldWorks.SketchLine
    Dim feat As SldWorks.Feature
    Dim SelMan As SldWorks.SelectionMgr
    Sub main()

    Set swApp = New SldWorks.SldWorks

    Set Part = swApp.ActiveDoc
    Set SelMan = Part.SelectionManager
    Set FeatMan = Part.FeatureManager
    Set feat = SelMan.GetSelectedObject4(1)
    Set ThisPoint = SelMan.GetSelectedObject4(2)

    Part.ClearSelection

    feat.Select2 False, 0
    ThisPoint.Select3 True, 1, Nothing

    FeatMan.FeatureExtrusion True, False, False, 3, 0, 0.00254, 0.00254,
    False, False, False, False, 0.01745329251994, 0.01745329251994, False,
    False, False, False, 1, 1, 1

    Part.SelectionManager.EnableContourSelection = 0
    Part.ClearSelection

    End Sub
     
    Sean Phillips, Oct 28, 2003
    #6
  7. Works swell. I'm not sure what you changed but I will look at it.

    I appreciate it

    Corey Scheich
     
    Corey Scheich, Oct 29, 2003
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.