Error by placing partlist on drawing

Error by placing partlist on drawing

Anonymous
Not applicable
426 Views
2 Replies
Message 1 of 3

Error by placing partlist on drawing

Anonymous
Not applicable

Hi,

 

i sometimes get the following error by placing a partlist on a inventor DWG

 

"Object of type 'System.UInt32' cannot be converted to type 'Inventor.CommandTypesEnum"

 

Why is that?

 

I use this VB.NET code:

Dim oDrawDoc As Inventor.DrawingDocument
oDrawDoc = m_inventorApplication.ActiveDocument

Dim oSheet As Inventor.Sheet
oSheet = oDrawDoc.ActiveSheet

Dim oDrawingView As Inventor.DrawingView
oDrawingView = oSheet.DrawingViews.Item(1)

Dim oRefDoc As Inventor.AssemblyDocument
oRefDoc = oDrawingView.ReferencedFile.ReferencedDocument

Dim oBOM As Inventor.BOM
oBOM = oRefDoc.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
                    
Dim oBOMView As Inventor.BOMView
oBOMView = oBOM.BOMViews.Item("Structured")

Dim oPoint2D As Inventor.Point2d
oPoint2D = m_inventorApplication.TransientGeometry.CreatePoint2d(66,0) 

Dim oPartList As Inventor.PartsList
oPartList = oSheet.PartsLists.Add(oDrawingView, oPoint2D, Inventor.PartsListLevelEnum.kStructured, Nothing, 1, False) 


 

Geert

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

Owner2229
Advisor
Advisor

Hmm, that's strange. When it throws the error again, click on the second error tab. You can read there some more info about the error.

 

Also, you can shorten your code like this (orange is what I've changed):

 

Dim oDrawDoc As Inventor.DrawingDocument = m_inventorApplication.ActiveDocument
Dim oSheet As Inventor.Sheet = oDrawDoc.ActiveSheet
If oSheet.DrawingViews.Count = 0 Then Exit For Dim oDrawingView As Inventor.DrawingView = oSheet.DrawingViews.Item(1) Dim oRefDoc As Inventor.AssemblyDocument = oDrawingView.ReferencedFile.ReferencedDocument Dim oBOM As Inventor.BOM = oRefDoc.ComponentDefinition.BOM oBOM.StructuredViewEnabled = True Dim oBOMView As Inventor.BOMView = oBOM.BOMViews.Item("Structured") Dim oPoint2D As Inventor.Point2d = m_inventorApplication.TransientGeometry.CreatePoint2d(66, 0)
Dim oLevel As Inventor.PartsListLevelEnum = Inventor.PartsListLevelEnum.kStructured
Dim oPartList As Inventor.PartsList = oSheet.PartsLists.Add(oDrawingView, oPoint2D, oLevel, Nothing, 1, False)
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Hi Mike,

 

thanks for your reply.

This code was a snipset of the original code, but I just found the solution by myself

 

I just put oBOM.StructuredViewFirstLevelOnly = True in the code and now it runs great.

 

regards,

 

Geert

0 Likes