End of Part Marker questions

End of Part Marker questions

Anonymous
Not applicable
1,425 Views
3 Replies
Message 1 of 4

End of Part Marker questions

Anonymous
Not applicable

Is there an event for when the End of Part marker is moved?

 

Once I know the EOP position using GetEndOfPartPosition(), is there a way to traverse through only the features that are after the EOP marker?

 

Thanks

0 Likes
1,426 Views
3 Replies
Replies (3)
Message 2 of 4

YuhanZhang
Autodesk
Autodesk

Currently there is no event to watch the browse node move.

 

You can check the PartFeature.HealthStatus, if the value is kBeyondStopNodeHealth that means the feature is under the End Of Part marker.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 4

ekinsb
Alumni
Alumni

Rocky is correct that there isn't a specific event to notify you when the end of part marker is moved.  However there are some higher level events that you can sometime use to respond to more granular activity within Inventor.  Here's a small prototype is used to test handling the end of part marker change.  It's reacting to the OnDocumentChange event which occurrs when any change at all occurs within a document.  It provides some context about what the change is and in this case reports it as a "Reorder Feature" operation.  To determine if it's a standard feature reorder or an end of part marker change I check the position of the end of part marker before and after the change and if it's moved then I assume the end of part marker has changed.  If it has changed then it reports all of the features in the tree after it.

 

To test this create a new form in VBA.  Select the form and in the Properties window set the ShowModal property to False.  Copy the code below into the code window for the form.  Run the form and move the end of part marker.  It should report the change.

 

I wouldn't recommend implementing your final version of this in VBA, but it is a good way to quickly test something, like I've done here.

 


Private WithEvents appEvents As ApplicationEvents
Private currentAfter As Object
Private currentBefore As Object


Private Sub appEvents_OnDocumentChange(ByVal DocumentObject As Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal ReasonsForChange As CommandTypesEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
    If Context.count > 0 Then
        If Context.value("InternalName") = "Reorder Feature" Then
            Dim partDoc As PartDocument
            If BeforeOrAfter = kBefore Then
                ' Record the current position of the end of part marker.
                Set partDoc = DocumentObject
                Call partDoc.ComponentDefinition.GetEndOfPartPosition(currentBefore, currentAfter)
            Else
                Set partDoc = DocumentObject
                Dim newAfter As Object
                Dim newBefore As Object
                Call partDoc.ComponentDefinition.GetEndOfPartPosition(newBefore, newAfter)
               
                Dim featureList As String
                If Not newAfter Is Nothing Then
                    ' Check to see if it's changed.
                    Dim bFoundFeature As Boolean
                    bFoundFeature = False
                    If Not currentBefore Is newBefore Or Not currentAfter Is newAfter Then
                        ' Build a list of the features after the end of part marker.
                        Dim featureNode As BrowserNode
                        For Each featureNode In partDoc.BrowserPanes.ActivePane.TopNode.BrowserNodes
                            If Not featureNode.NativeObject Is Nothing Then
                                If TypeOf featureNode.NativeObject Is PartFeature Or TypeOf featureNode.NativeObject Is WorkPlane Or TypeOf featureNode.NativeObject Is WorkAxis Or TypeOf featureNode.NativeObject Is WorkPoint Then
                                    Dim nativeFeature As Object
                                    Set nativeFeature = featureNode.NativeObject
                                    If nativeFeature Is newAfter Then
                                        bFoundFeature = True
                                    End If
                                   
                                    If bFoundFeature Then
                                        If featureList = "" Then
                                            featureList = "    " & nativeFeature.Name
                                        Else
                                            featureList = featureList & vbCrLf & "    " & nativeFeature.Name
                                        End If
                                    End If
                                End If
                            End If
                        Next
                    End If
                   
                    Set currentAfter = Nothing
                    Set currentBefore = Nothing
                   
                    MsgBox "Features after end of part marker: " & vbCrLf & featureList
                    Debug.Print ""
                    Debug.Print "Features after end of part marker: " & vbCrLf & featureList
                Else
                    MsgBox "No features are after the end of part marker."
                End If
            End If
        End If
    End If
End Sub

Private Sub UserForm_Initialize()
    Set appEvents = ThisApplication.ApplicationEvents
End Sub


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 4 of 4

Anonymous
Not applicable

Perfect.  That's exactly what I was looking for.

Thanks Brian.

 

Jeff

0 Likes