Issue casting ModelGeometry to EdgeProxy

Issue casting ModelGeometry to EdgeProxy

etckerry
Enthusiast Enthusiast
557 Views
2 Replies
Message 1 of 3

Issue casting ModelGeometry to EdgeProxy

etckerry
Enthusiast
Enthusiast

Hello,

 

I'm having an issue with code that's been deployed for several years (although possibly not used very often).  This code ran fine with Inventor 2016, but we're now using 2018 and appear to be having an issue.  This is the code:

 

Dim curve As DrawingCurveSegment
        curve = CType(invApp.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter,
                                                 "Select an item"), DrawingCurveSegment)

        Try
            ProcessSelectedOccurrence(CType(curve.Parent.ModelGeometry, Inventor.EdgeProxy).ContainingOccurrence)
            Exit Sub
        Catch ex As Exception
            MessageBox.Show("Failed to convert to edge proxy:  " + ex.ToString())
        End Try

And this is the error message:

error.png

 

I've tried just about every type of proxy in the Inventor namespace but I get the same results.  EdgeProxy is the one that I expect to work for the geometry that I'm selecting.

 

Any ideas?

 

Thanks,

 

Kerry

 

0 Likes
Accepted solutions (1)
558 Views
2 Replies
Replies (2)
Message 2 of 3

J-Camper
Advisor
Advisor
Accepted solution

I'm assuming this is only a portion of the code and that "ProcessSelectedOccurrence" is a sub routine. 

 

A debugging message box can be added to find out exactly what type of object Inventor is seeing @ the selection. code posted below:

 

 

Dim curve 'As DrawingCurveSegment
    curve = CType(ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter,
                                             "Select an item"), DrawingCurveSegment)
	'Debug to check object type:
	MessageBox.Show(curve.Parent.ModelGeometry.Type, "Check type")
	
    Try
        'ProcessSelectedOccurrence(CType(curve.Parent.ModelGeometry, Inventor.EdgeProxy).ContainingOccurrence)
        Exit Sub
    Catch ex As Exception
        MessageBox.Show("Failed to convert to edge proxy:  " + ex.ToString())
    End Try

Correspond the number it shows HERE  .  Not sure what the subroutine "ProcessSelectedOccurrence" is doing with the Object, if you are actually selecting an Edge Proxy object, but I have had success referring to ModelGeometry types as:

 

 

ObjectTypeEnum.kEdgeObject
ObjectTypeEnum.kEdgeProxyObject

 

 

0 Likes
Message 3 of 3

JelteDeJong
Mentor
Mentor

just a line of code that i use to get the object type of an unknow object. it will directly tell you what kind of object you have.

MsgBox(CType(myUnknowObject.type, ObjectTypeEnum).ToString())

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes