Get drawingcurves from nested part in drawingview gives error

Get drawingcurves from nested part in drawingview gives error

Anonymous
Not applicable
569 Views
1 Reply
Message 1 of 2

Get drawingcurves from nested part in drawingview gives error

Anonymous
Not applicable

Hi,

 

 

when i select a nested part in the modelbrowser and try to get it's drawingcurves my routine gets a error: "The parameter is incorrect" on 

oCurveEnum = oDrawView.DrawingCurves(oNativeObj)

 Why is that?

When i select a part direct under the main assembly all works fine, but when i select a part under a subassembly i get the error.

 

Kind Regards,

 

Geert

Inventor Pro 2017

 

 

 

    Private Function GetAllDrawingCurvesOfSelectedBrowserNodes(ByVal oStartBrowserNode As Inventor.BrowserNode, ByVal oObjectCollection As Inventor.ObjectCollection) As Inventor.ObjectCollection
        Dim oINVDrawingDoc As Inventor.DrawingDocument = m_inventorApplication.ActiveDocument
        Dim oSheet As Inventor.Sheet = oINVDrawingDoc.ActiveSheet

        For Each oBrowserNode As Inventor.BrowserNode In oStartBrowserNode.BrowserNodes
            Try
                Dim oNativeObj As Object
                oNativeObj = oBrowserNode.NativeObject

                If TypeName(oNativeObj) = "ComponentOccurrence" Then
                    If oBrowserNode.Selected = True Then
                        'Dim oCompOcc As Inventor.ComponentOccurrence = oNativeObj
                        Try
                            For Each oDrawView As Inventor.DrawingView In oSheet.DrawingViews
                                'check of drawingView is shaded, dan overslaan
                                If oDrawView.ViewStyle <> Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle Then
                                    Dim oCurveEnum As Inventor.DrawingCurvesEnumerator
                                    Try
                                        oCurveEnum = oDrawView.DrawingCurves(oNativeObj)    'oCompOcc
                                        Dim oCurve As Inventor.DrawingCurve
                                        Dim oSegment As Inventor.DrawingCurveSegment
                                        'add segments to collection to be moved to required layer
                                        For Each oCurve In oCurveEnum
                                            For Each oSegment In oCurve.Segments
                                                Call oObjectCollection.Add(oSegment)
                                            Next
                                        Next
                                    Catch ex As Exception

                                    End Try
                                End If
                            Next
                        Catch ex As Exception

                        End Try

                    Else    'check SubBrowserNodes
                        Call GetAllDrawingCurvesOfSelectedBrowserNodes(oBrowserNode, oObjectCollection)
                    End If
                End If
            Catch ex As Exception

            End Try
        Next

        Return oObjectCollection
    End Function

 Get drawingCurves.jpg

0 Likes
Accepted solutions (1)
570 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Hi,

 

I solved it myself.

For those who have the same problem here is the solution:

 

Cheers,

 

Geert

 

   Private Function GetAllDrawingCurvesOfSelectedBrowserNodes(ByVal oStartBrowserNode As Inventor.BrowserNode, ByVal oObjectCollection As Inventor.ObjectCollection) As Inventor.ObjectCollection
        Dim oINVDrawingDoc As Inventor.DrawingDocument = m_inventorApplication.ActiveDocument
        Dim oSheet As Inventor.Sheet = oINVDrawingDoc.ActiveSheet

        'loop through browsernodes of startBrowserNode
        For Each oBrowserNode As Inventor.BrowserNode In oStartBrowserNode.BrowserNodes
            Try
                Dim oNativeObj As Object = oBrowserNode.NativeObject
                'Check if browsernode is of type ComponentOccurrence
                If TypeName(oNativeObj) = "ComponentOccurrence" Then
                    'check if browsernode is selected
                    If oBrowserNode.Selected = True Then
                        Try
                            'loop through all drawingviews to get all teh drawingcurves to change layer
                            For Each oDrawView As Inventor.DrawingView In oSheet.DrawingViews
                                'check if drawingView is not shaded
                                If oDrawView.ViewStyle <> Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle Then
                                    Dim oCurveEnum As Inventor.DrawingCurvesEnumerator = Nothing
                                    Try
                                        'get all the drawingcurves of selected browsernode in this drawingview
                                        oCurveEnum = oDrawView.DrawingCurves(oNativeObj)
                                    Catch
                                        Try
                                            'nested part occurrence requires another approach
                                            Dim oParentCompOcc As Inventor.ComponentOccurrence = oStartBrowserNode.NativeObject
                                            Dim oCompOccProxy As Object = Nothing
                                            Call oParentCompOcc.CreateGeometryProxy(oNativeObj, oCompOccProxy)
                                            oCurveEnum = oDrawView.DrawingCurves(oCompOccProxy)
                                        Catch

                                        End Try
                                    End Try

                                    'add segments to collection to be moved to required layer
                                    For Each oCurve As Inventor.DrawingCurve In oCurveEnum
                                        For Each oSegment As Inventor.DrawingCurveSegment In oCurve.Segments
                                            Call oObjectCollection.Add(oSegment)
                                        Next
                                    Next
                                End If
                            Next
                        Catch ex As Exception

                        End Try

                    Else    'check SubBrowserNodes
                        Call GetAllDrawingCurvesOfSelectedBrowserNodes(oBrowserNode, oObjectCollection)
                    End If
                End If
            Catch ex As Exception

            End Try
        Next

        Return oObjectCollection
    End Function
0 Likes