Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I'm starting with the ilogic drawing code. I want to show the inividual mass propety for all of he components of the assembly, but I can't get it to work. I'm tryin to add the new column at the end of the BOM, but it gives me the following error:
Error in rule: 1, in document: X.iam
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
My code is as follows:
'/////////////////// C O D E ///////////////////////'
Sub Main() Dim oPartDoc As Document oPartDoc = ThisDoc.Document Dim oDrawingDoc As DrawingDocument Dim typ As DocumentTypeEnum typ = ThisDoc.Document.Type oDrawingDoc = ThisApplication.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2021\Templates\en-US\BOHN.idw", True) Call ansicht(oPartDoc,oDrawingDoc) End Sub '////////// Place views //////////////////////////////////////////////////////////////////////////////// Sub ansicht(oPartDoc, oDrawingDoc) Dim oSheet As Sheet Dim oDoc1 As String = ThisDoc.FileName(False) Dim oBaseViewOptions As NameValueMap Dim oPoint0 As Point2d Dim oView0 As DrawingView SpiderID = Right(oDoc1, Len(oDoc1)) ViewScale = 0.5 oSheet = oDrawingDoc.Sheets.Item(1) oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap oBaseViewOptions.Add(SpiderID & ".ipt", False) oPoint0 = ThisApplication.TransientGeometry.CreatePoint2d(37,15) ' front view oView0 = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint0, ViewScale, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, "View1") Dim oPview1 As DrawingView Dim oPview2 As DrawingView Dim oPview3 As DrawingView Dim oPview4 As DrawingView Dim oPoint1 As Point2d Dim oPoint2 As Point2d Dim oPoint3 As Point2d Dim oPoint4 As Point2d oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(60, 15) oPview1 = oSheet.DrawingViews.AddProjectedView(oView0, oPoint1, kHiddenLineRemovedDrawingViewStyle, ViewScale) oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(10, 15) oPview2 = oSheet.DrawingViews.AddProjectedView(oView0, oPoint2, kHiddenLineRemovedDrawingViewStyle, ViewScale) oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(37, 42) oPview3 = oSheet.DrawingViews.AddProjectedView(oView0, oPoint3, kHiddenLineRemovedDrawingViewStyle, ViewScale) oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(60, 42) oPview4 = oSheet.DrawingViews.AddProjectedView(oView0, oPoint4, kHiddenLineRemovedDrawingViewStyle, ViewScale) Call BOM(oDrawingDoc,oSheet,oView,oPartDoc) End Sub '////////// B O M //////////////////////////////////////////////////////////////////////////////// Sub BOM(oDrawingDoc,oSheet,oView0,oPartDoc) Dim oBOM As BOM Dim oPartsLists As PartsLists Dim oPartsList As PartsList 'Try to get the first view on the sheet Try oView0 = oSheet.DrawingViews(1) Catch MessageBox.Show("There is no view in the drawing", _ "Export du dessin", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try 'gets the refference model oModelDoc = oPartDoc 'BOM database oBOM = oModelDoc.ComponentDefinition.BOM ' enable the BOM view oBOM.PartsOnlyViewEnabled = True 'get the PartsLists collection oPartsLists = oSheet.PartsLists 'clean up part lists on the drawing For Each oPartsList In oPartsLists oPartsList.Delete Next 'Setting BOM position Dim BomPlacementPoint As Point2d Dim oBorder As Border = oSheet.Border BomPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d _ (0, oBorder.RangeBox.MaxPoint.Y) 'Create new partsList oPartsList = oPartsLists.Add(oView0, BomPlacementPoint, PartsListLevelEnum.kPartsOnly) 'specify property set Dim oPropSetID As String Dim oPropType As String Dim oPropSet As PropertySets = oPartDoc.PropertySets Dim oProp As PropertySet Dim oMass As String oProp = oPropSet.Item("Design tracking properties") 'specify the mass property oMass = oProp.Item(39).Name 'specify the property oProp = oPropSet.Item(39) oPropType = Inventor.PropertyTypeEnum.kVolumePartsListProperty oPropSetID = oProp.InternalName 'Set the new column position oColTargetIndex = 5 oColumnInsertBefore = False 'add column oCol = oPartsList.PartsListColumns.Add(oPropType, oPropSetID, oProp.PropId, oColTargetIndex, oColumnInsertBefore) End Sub
Thanks for the help.
Solved! Go to Solution.