Anonymous
399 Views, 2 Replies
02-13-2017
11:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-13-2017
11:53 PM
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
Solved! Go to Solution.
02-14-2017
03:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-14-2017
03:33 AM
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
- - - - - - - - - - - - - - -
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
02-14-2017
03:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-14-2017
03:44 AM
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