error: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingCurveSegment'. After 2024.2 update

error: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingCurveSegment'. After 2024.2 update

Nicholasm4Z8CU
Explorer Explorer
2,122 Views
6 Replies
Message 1 of 7

error: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingCurveSegment'. After 2024.2 update

Nicholasm4Z8CU
Explorer
Explorer

Good day, 

we have some legacy code in our company used to add some custom section symbols onto the inventor default section line. 

After updating to 2024.2, I have been getting an error:

 

"

Error on line 84 in rule: # Section Symbol Wizard_Copy, in document: 339255-100 TO XXX - MILL 4 TROUGH.idw

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingCurveSegment'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{EEE9F58F-FD0B-4862-AE21-BAE203DFE23E}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

"

I tried to google this error and didn't have any luck finding something that applied to our issue.

I have attached the code for reference. Unfortunately I am a novice when it comes to coding illogic and the person who originally created the code hasn't worked with us for years now.

0 Likes
Accepted solutions (1)
2,123 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @Nicholasm4Z8CU.  That type of error generally just means that there is a Type mismatch, and the system could not convert the one Type of object to the other Type of object to make it work.  In this case, I see that Line 84 contains the following line of code:

 

oDLine = oCommandMgr.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select the LINE")

 

...then when I scroll up from that position to find where that 'oDLine' variable was 'declared', I find that on Line 49, as follows:

 

Dim oDLine As DrawingCurveSegment

 

That variable's Type appears to be compatible to me, and the spelling in both cases appears to be correct.  So, I do not know why it would be having a problem at that line yet.  Was this code used within something like an Inventor.ApplicationAddIn?  I noticed that it contains multiple Class blocks of code, which contain pretty much all the code, except for a single Sub Main block of code that creates a new 'instance' of one of those Classes.  That combined with how it is getting the Inventor.Application seem to indicate that it is being used externally, instead of simply within an iLogic rule.

 

Edit:  Also, when I copy that code over into a new iLogic rule to review it, then attempt to 'save' it, I get an error saying that it could not find the library mentioned in Line 1. (X:\CAD Library\iLogic\SectionSymToolBox.dll).  That is perfectly normal on my end, because I do not have that referenced DLL file on my computer, like you have on yours.  But I can not be sure if there may be something about that DLL file that may need to be updated either.  But that does not seem likely at this point.  The DrawingCurveSegment Type was established back in version 11, and the Pick method was established in 2011.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

Nicholasm4Z8CU
Explorer
Explorer

Thanks for the reply,

As far as I know this code is used in the drawing environment.  i'm not sure if there would have been a  Inventor.ApplicationAddIn .  The code has worked fine for years up until this latest inventor update. some of my colleagues haven't updated yet and the code works for them.   Perhaps there is an add in that no longer exist in this new update? 

0 Likes
Message 4 of 7

Nicholasm4Z8CU
Explorer
Explorer
i am able to access this .dll file, but it appears that this forum doesn't allow me to attach .dll files.
is there a another way i can send it, or a way i can check if that is giving me the issues?
0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor

Not sure.  It may be possible through a private message (hover your mouse over someone else's username, then click Send Private Message).  But I may not actually be able to inspect that type of file properly anyways.  Those types of files are often created through an application such as Microsoft Visual Studio, and they often can not be reviewed or edited by common text editors.  I do have an installation of VS 2019 Community, but I am not experienced with DLL file creation/editing, or creating Inventor add-ins, which is often what DLL's are used for in this context.  Maybe one of the other super helpful members here on the forum would be able to help out on this case better than I can.  Sorry.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

Michael.Navara
Advisor
Advisor
Accepted solution

I look at your code and there are few strange parts.

 

1) The main breaking change in 2024.2 is different picked entity when you pick section line. Before 2024.2 it was DrawingCurveSegment, now it is SketchLine.

- I add new handling method for this and keep the previous too. You can use this code for all versions (tested 2022, 2024.2)

 

2) In the iLogic rules avoid to use Marshal.GetActiveObject and CreateInstance. Always use the appropriate entry-point provided by iLogic. In this case it is variable ThisApplication

- I comment out the class CL_InventorApp and replace this part of code in the constructor. I need to pass ThisApplication variable from main rule to class instance as the parameter inventorApp.

 

3) Avoid to call any "business logic" code from constructor. Always add this code to separate Sub or Function.

- I move the business logic to separate method Start() 

 

4) External DLL library contains only simple dialog from point of view of this rule. For testing purposes I need to create new one.

- I add full definition of this form as a part of the rule. You can use my implementation without reference to the external DLL or remove the last class and use your original implementation from DLL

 

I hope it helps

Thanks to the @WCrihfield  for notification.

Message 7 of 7

Nicholasm4Z8CU
Explorer
Explorer

seems to work now, thank you for the help !

0 Likes