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

Jul 10, 2004 8 Replies

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


check out FeatureManager.EditRollback in sw03 or newer, or try ModelDoc2.EditRollback2 on older versions. Hope it helps.

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

FeatureManager.editRollback(swMoveRollbackBarToEnd ,Nothing) should work

Evan

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

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

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

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, "")

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, ""

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required