Move EOP Marker Step by Step in the modeling tree

Move EOP Marker Step by Step in the modeling tree

danijel.radenkovic
Collaborator Collaborator
1,630 Views
6 Replies
Message 1 of 7

Move EOP Marker Step by Step in the modeling tree

danijel.radenkovic
Collaborator
Collaborator

Hello,

I am iterested if is there a VBA code example to move EOP ( End Of Part) Marker from the Top to the Bottom and when macro catch some feature crash, then EOP need to stop moving.

I would appreciate any help.

 

Best regards

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Accepted solutions (2)
1,631 Views
6 Replies
Replies (6)
Message 2 of 7

ekinsb
Alumni
Alumni
Accepted solution

Are you looking for something like this?

 

Public Sub RecomputeToFailure()
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument
    Dim partDef As PartComponentDefinition
    Set partDef = partDoc.ComponentDefinition
    
    ' Reposition the stop node to the top.
    Call partDef.SetEndOfPartToTopOrBottom(True)
    
    ' Get the browser.
    Dim browser As BrowserPane
    Set browser = partDoc.BrowserPanes.Item(1)
    
    Dim topNode As BrowserNode
    Set topNode = browser.topNode
    
    Dim childNode As BrowserNode
    For Each childNode In topNode.BrowserNodes
        Dim ent As Object
        Set ent = childNode.NativeObject
        
        ' Check to see if it's an entity type that the stop node can be positioned to.
        If Not ent Is Nothing Then
            If TypeOf ent Is PartFeature Then
                Dim feature As PartFeature
                Set feature = ent
                
                Call feature.SetEndOfPart(False)
                
                If feature.HealthStatus <> kUpToDateHealth Then
                    MsgBox feature.name & " Failed to successfully compute."
                    Exit Sub
                End If
            ElseIf TypeOf ent Is WorkPlane Then
                Dim wPlane As WorkPlane
                Set wPlane = ent
                
                Call wPlane.SetEndOfPart(False)
                If wPlane.HealthStatus <> kUpToDateHealth Then
                    MsgBox wPlane.name & " Failed to successfully compute."
                    Exit Sub
                End If
            ElseIf TypeOf ent Is WorkAxis Then
                Dim wAxis As WorkAxis
                Set wAxis = ent
                
                Call wAxis.SetEndOfPart(False)
                If wAxis.HealthStatus <> kUpToDateHealth Then
                    MsgBox wAxis.name & " Failed to successfully compute."
                    Exit Sub
                End If
            ElseIf TypeOf ent Is WorkPoint Then
                Dim wPoint As WorkPoint
                Set wPoint = ent
                
                Call wPoint.SetEndOfPart(False)
                If wPoint.HealthStatus <> kUpToDateHealth Then
                    MsgBox wPoint.name & " Failed to successfully compute."
                    Exit Sub
                End If
            ElseIf TypeOf ent Is sketch Then
                Dim sk As PlanarSketch
                Set sk = ent
                
                Call sk.SetEndOfPart(False)
                If sk.HealthStatus <> kUpToDateHealth Then
                    MsgBox sk.name & " Failed to successfully compute."
                    Exit Sub
                End If
            End If
        End If
        
        ThisApplication.ActiveView.Update
    Next
    
    MsgBox "Successfully computed model."
End Sub

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 7

danijel.radenkovic
Collaborator
Collaborator

Hello Mr. Ekins,

Yes, I am looking for that and I tried code but I am getting the message which says:

error.png

 

Problematical line.

    Dim topNode As BrowserNode
    Set topNode = browser.topNode

Thank you very much.

Regards

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 4 of 7

Anonymous
Not applicable
Accepted solution

Change this:

 ' Get the browser.
    Dim browser As BrowserPane
    Set browser = partDoc.BrowserPanes.Item(1)

To this:

 ' Get the browser.
    Dim browser As BrowserPane
    Set browser = partDoc.BrowserPanes.Item("Model")

And it will work.

Message 5 of 7

danijel.radenkovic
Collaborator
Collaborator

Hello Ken,

Thank you very much for the help. It works perfect!

What if I want to move the node on some feature in the middle of the tree, not on the top?

 

 

Best regards

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 6 of 7

Anonymous
Not applicable

If you follow the tutorial at the link below and combine the code found in the form with the code from above you will have a nice control for the macro.

 

http://modthemachine.typepad.com/my_weblog/2011/06/stepping-through-the-features-of-a-model.html

0 Likes
Message 7 of 7

Maxim-CADman77
Advisor
Advisor
I wonder which is the best way to limit EoP moving up to just below the first feature in the tree?
Is there any ready for use counter of features that are above the EoP-marker?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes