Interop Exception for View.DrawingCurves

Interop Exception for View.DrawingCurves

varad.keshatwar
Contributor Contributor
2,726 Views
22 Replies
Message 1 of 23

Interop Exception for View.DrawingCurves

varad.keshatwar
Contributor
Contributor

Hello Guys,
I am facing an error with the following API
View.DrawingCurves(OModel as Object)
I am facing this Interop error in Visual Basic, while using Inventor 2024 DLL.
I have attached the screenshots of all the errors here with, also attaching my code snippet.

 

Public Overridable Function GetGrooveCurvePoint(iGrooveNo As Integer) As Point2d
        Try
            Dim onumer As DrawingCurvesEnumerator = Nothing
            Dim oCurveLeft As DrawingCurve
            Dim dRefXMin As Double = 1000

 

            'onumer = oViewSection.DrawingCurves(oIptDoc.ComponentDefinition.Features(GlobalCADRes.strGroove + " " & iGrooveNo))
            Dim oFeature As Object = CType(oIptDoc.ComponentDefinition.Features(GlobalCADRes.strGroove & " " & iGrooveNo), Object)
            onumer = oViewSection.DrawingCurves(oFeature)

 

            'Get the Longest Curve of groove
            For Each oDrawCurve As DrawingCurve In onumer
                If oDrawCurve.StartPoint.X > oViewSection.Center.X And oDrawCurve.EndPoint.X > oViewSection.Center.X Then
                    If Math.Round(oDrawCurve.StartPoint.X, 2) = Math.Round(oDrawCurve.EndPoint.X, 2) Then
                        'If Math.Round(oDrawCurve.StartPoint.Y, 2) <> Math.Round(oDrawCurve.EndPoint.Y, 2) Then     ''''change by Nilesh for 69769 on 29/09/11
                        If oDrawCurve.EndPoint.X < dRefXMin Then
                            dRefXMin = oDrawCurve.EndPoint.X
                            oCurveLeft = oDrawCurve
                            'End If
                        End If
                    End If
                End If
            Next

 

            If oCurveLeft IsNot Nothing Then
                If oCurveLeft.StartPoint.X > oCurveLeft.EndPoint.X Then
                    Return oCurveLeft.StartPoint
                Else
                    Return oCurveLeft.EndPoint
                End If
            End If

 

            Return Nothing
        Catch ex As Exception
        End Try
    End Function

 

 

0 Likes
2,727 Views
22 Replies
Replies (22)
Message 21 of 23

marcin_otręba
Advisor
Advisor

hi, so why you just don't leave sketch mode ? or stop execution if drawing is in sketch mode ?

If drawing is not in sketch ode does it work as it should ? after update ?

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes
Message 22 of 23

Stakin
Collaborator
Collaborator

This is a preset mode of the program, not an error.


@varad.keshatwar wrote:

Hello Inventor Community,

@Stakin @jjstr8 @marcin_otręba 
Guys, I have observed one more issue with the following API.

DrawingView.DrawingCurves([ModelObject] As Variant) As DrawingCurvesEnumerator 

I have observed, when the sheet is sketch mode, and if requires update in that case too this API fails throws the same threw an exception of type 'System.Runtime.InteropServices.COMException'. Even Sheet update and Doc update does not work in this case.
Please refer screenshot attached

varadkeshatwar_0-1742223811010.png

 

PS: Guyz, I'm facing daily new issues with this API. Your guidance will be of great use if you help me to point this to any Autodesk executive ASAP😥😟


 

0 Likes
Message 23 of 23

EngrSolutions
Participant
Participant

@varad.keshatwar I have found another unexpected issue.

 

I have been trying to find all the drawings curves on a particular view for a specific ComponentOccurrence. I keep getting the following error

 

EngrSolutions_0-1760373178564.png

 

It seems as if it matters how the document object is retrieved. In the error above I am passing the appropriate Document (oDoc) into the method. If I find the AssemblyDocument from the View object, then this error goes away and works as expected.

 

// Get the Referenced Document
//AssemblyDocument oAssyDoc = (AssemblyDocument)oDoc;
AssemblyDocument oAssyDoc = (AssemblyDocument)oShellView.ReferencedDocumentDescriptor.ReferencedDocument;
// Get the ComponentOccurrence
object oOcc = InventorUtilities.FindPartOccurrenceByID2(oAssyDoc, "1696041893");
oCount = oShellView.DrawingCurves[oOcc];
MessageBox.Show(oCount.Count.ToString(), "Title");

 

The paths of both oDoc and oAssyDoc are pointing to the same document

 

EngrSolutions_1-1760373565043.png

 

Is this expected behaviour?

 

0 Likes