Type Mismatch on GetInspectionDimensionData(), yet SetInspectionDimensionData() works

Type Mismatch on GetInspectionDimensionData(), yet SetInspectionDimensionData() works

Ethibaudeau
Advocate Advocate
646 Views
3 Replies
Message 1 of 4

Type Mismatch on GetInspectionDimensionData(), yet SetInspectionDimensionData() works

Ethibaudeau
Advocate
Advocate

I am really confused on the error I am getting when using GetInspectionDimensionData(). If I select a dimension which has inspection data turned on already:

Dim shape As InspectionDimensionShapeEnum
Dim label As String
Dim rate As String
Dim oObject As Object
oObject = oDrawingDoc.SelectSet.Item(1)
oObject.GetInspectionDimensionData(shape, label, rate)

I get:

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

 

Yet if I change it slightly to SetInspectionDimensionData(), and set values to the three variables, it works no problem:

Dim shape As InspectionDimensionShapeEnum = kAngularEndsInspectionBorder 
Dim label As String = "2"
Dim rate As String = "1"
Dim oObject As Object
oObject = oDrawingDoc.SelectSet.Item(1)
oObject.SetInspectionDimensionData(shape, label, rate)

 

So based on using Set instead of Get, I think I have the variable types set correctly...

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

tfrohe_LSI
Advocate
Advocate
Accepted solution

Try creating oObject as DrawingDimension instead of an Object.

0 Likes
Message 3 of 4

Ethibaudeau
Advocate
Advocate

That's really interesting. That works, thanks! I think I can see why, but maybe I someone can help me out with programming style.

 

In the real code I'm working on I have a VB List of objects. Basically I filled this list by collecting all the drawing dimensions, leader notes, chamfer notes, and sketched symbols into a VB List. But since they are all different types, I created the list using "Dim oAnnotations As New List(Of Object)".

I was able to get the rest of my code working by checking other properties first, and see it was a drawing dimension, copy it locally to a new object "Dim testObject As DrawingDimension". I'd love to hear what the proper way of doing this is. I had another issue recently where properties were not availalbe where I thought they should be, and I think its related to this same thing.

0 Likes
Message 4 of 4

tfrohe_LSI
Advocate
Advocate
While I cannot answer the why, you might consider using a different construct to contain your objects. Inventor has an ObjectCollection Object that you can use in place of the list.

Each object in the Object Collection has a type property which can identify the object type from ObjectTypeEnum.

You can read about it here. https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-6C4C98CB-8909-48EF-B73E-F663424D5B41

Hope this helps.
0 Likes