Need API help- how do you roll featuremanager bar to the end?

Discussion in 'SolidWorks' started by Mike, Jul 10, 2004.

  1. Mike

    Mike Guest

    Hello,

    When I'm using "Part.InsertSketch2 True" to create sketches in a
    macro, then later try to use "Part.FeatureManager.FeatureCut" to
    extrude the sketches into cuts, the featuremanager shows the sketches
    grayed out and the cuts don't work. I have a feeling when I try to
    select the sketches in the macro to extrude them, they aren't being
    selected because you cannot select grayed out sketches in the feature
    manager manually. When I right-click on them manually, I can choose
    "roll forward" and then they are no longer grayed out. How do I
    prevent them from being grayed out during the macro, or how do I roll
    the bar to the end in the macro?

    Thanks,
    Mike
     
    Mike, Jul 10, 2004
    #1
  2. Mike

    rocheey Guest

    How do I prevent them from being grayed out during the macro, or how do
    check out FeatureManager.EditRollback in sw03 or newer, or try
    ModelDoc2.EditRollback2 on older versions. Hope it helps.
     
    rocheey, Jul 10, 2004
    #2
  3. Mike

    Mike Guest

    I saw that, but I can't figure out how to make it work. Can you give
    me an example? How do I make it roll to the end without specifying
    the last item on the feature manager by name?

    Thanks,
    Mike
     
    Mike, Jul 11, 2004
    #3
  4. FeatureManager.editRollback(swMoveRollbackBarToEnd ,Nothing) should work

    Evan
     
    Evan T. Basalik, Jul 12, 2004
    #4
  5. Have you rolled the tree back in your macro. If not you may only need a
    rebuild. You can create geometry in a macro but you cannot reference it
    until you rebuild.

    Corey
     
    Corey Scheich, Jul 12, 2004
    #5
  6. Mike

    Mike Guest

    I can't get it to work, here's what I tried:

    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc
    Set FeatMgr = Part.FeatureManager
    .....

    When I try this:
    FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    or this

    FeatMgr.editRollback(0, Nothing)

    I get "syntax error" or "expected ="

    When I try this:

    Dim rollbackStatus
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    or

    Dim rollbackStatus As Boolean
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    or
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    I get "type mismatch"

    Any ideas?

    Thanks,
    Mike
     
    Mike, Jul 12, 2004
    #6
  7. Mike

    Mike Guest

    I tried this, but the rebuild doesn't seem to work: (I get status =
    false)

    boolstatus = Part.Rebuild(swForceRebuildAll)
    MsgBox ("status=" & boolstatus)
    Part.ClearSelection2 True
    boolstatus = Part.Extension.SelectByID("Sketch5", "SKETCH", 0, 0, 0,
    False, 0, Nothing)
    Part.FeatureManager.FeatureCut True, False, False, 0, 0, 0.01, 0.01,
    False, False, False, False, 0.01745329251994, 0.01745329251994, False,
    False, False, False, 0, 1, 1
    Part.SelectionManager.EnableContourSelection = 0


    I also tried rolling the feature manager to the end (since it is not
    at the end):

    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc
    Set FeatMgr = Part.FeatureManager
    .....

    When I try this:
    FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    or this

    FeatMgr.editRollback(0, Nothing)

    I get "syntax error" or "expected ="

    When I try this:

    Dim rollbackStatus
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    or

    Dim rollbackStatus As Boolean
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    or
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing)

    I get "type mismatch"

    Any ideas?

    Thanks,
    Mike
     
    Mike, Jul 14, 2004
    #7
  8. I Comented a little below

    I don't think you need a force rebuild just rebuild all should do
    Sometimes VB wants you to not have parentheses unless you are assigning a
    return value to a variable of some sort. for example either of these should
    get rid of that error.

    FeatMgr.editRollback swMoveRollbackBarToEnd, Nothing
    or
    retval = FeatMgr.editRollback(swMoveRollbackBarToEnd, Nothing) 'if retval is
    a variant or the specific return type of the feature for example boolean or
    object




    this is because Nothing is an object editRollback is looking for a value
    that can be a string either of these should get rid of that error.

    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, Empty)
    or
    rollbackStatus = FeatMgr.editRollback(swMoveRollbackBarToEnd, "")
     
    Corey Scheich, Jul 14, 2004
    #8
  9. Mike

    rocheey Guest

    The following is a snippet of code that Ive been using several times a
    week for the last couple of years. This is posted verbatim.

    ' roll back model to before next features are made
    MyModel.FeatureManager.EditRollback 4, "SideFlangeAlignmentSketch"

    (snip for brevity)

    ' Now roll model completely back and set the rest of the params
    MyModel.FeatureManager.EditRollback 1, ""
     
    rocheey, Jul 14, 2004
    #9
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.