SketchedSymbolDefinitions error

SketchedSymbolDefinitions error

Anonymous
Not applicable
655 Views
1 Reply
Message 1 of 2

SketchedSymbolDefinitions error

Anonymous
Not applicable

I'm getting an error with the sketchedsymbolslibrary object not iterating through the sketched symbol definitions that it has:

 


System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.SketchedSymbolDefinition'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A907AED3-A78F-11D5-8DF8-0010B541CAA8}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

   at TTSInventorTools.ClearanceDraw.CreateClearanceDrawing() in C:\Code\Inventor\TTS Inventor Tools\TTSInventorTools\TTSInventorTools\ClearanceDraw.vb:line 803

   at TTSInventorTools.ClearanceDraw.CreateClearance() in C:\Code\Inventor\TTS Inventor Tools\TTSInventorTools\TTSInventorTools\ClearanceDraw.vb:line 142

 

The previous error is thrown on line Dim ssd as ...  When I used a for each as method with defnition it errored out as well.

 'insert target symbol into document
        Dim symLibs As SketchedSymbolDefinitionLibraries = ClearanceDrawing.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries
        For Each symLib As SketchedSymbolDefinitionLibrary In symLibs
            If symLib.Name = "Clearance.idw" Then
                For i As Integer = 1 To symLib.SketchedSymbolDefinitions.Count
                    Dim ssd As SketchedSymbolDefinition = symLib.SketchedSymbolDefinitions.Item(i)
                    If ssd.Name = "TARGET" Then
                        ClearanceDrawing.SketchedSymbolDefinitions.AddFromLibrary(symLib, ssd.Name)
                    ElseIf ssd.Name = "AXLE LOAD RIGHT" Then
                        ClearanceDrawing.SketchedSymbolDefinitions.AddFromLibrary(symLib, ssd.Name)
                    ElseIf ssd.Name = "AXLE LOAD LEFT" Then
                        ClearanceDrawing.SketchedSymbolDefinitions.AddFromLibrary(symLib, ssd.Name)
                    End If
                Next
            End If
        Next

Please help to resolve, I would like to insert the sketched symbols from my definition library so I can place the symbols into my drawing document.

 

 

Thanks,

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

Anonymous
Not applicable
Accepted solution

the collection returns an enumeration of LibrarySketchedSymbolDefinition, that is the object type it is looking for.  To solve my problem, i defined the instance as Object, then queried it for Type, and got from the list 117498880 which is kLibrarySketchedSymbolDefinitionObject.  So there are 2:

SketchedSymbolDefinition - already embedded in document

LibrarySketchedSymbolDefinition - loaded from file stored in SketchedSymbolLibrary folder.

 

Very sneaky... an seemingly pointless.