
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Posted below is the iLogic code that I am planning on using to create a Parts List with the columns that I want included. The issue I have is that several lines have a "Reference to a non-shared member requires an object reference." error, I am not sure how to solve this problem and after finding other posts with similar problems it is not any clearer to me.
I have been using the Inventor 2021 API Help to get the code snippets and copied most of the sample code for creating a Parts List.
The code has been commented so that it hopefully makes sense what I am trying to do in each section.
Any help with this and learning what text from the syntax pages needs to be included when writing code would be much appreciated.
The specific lines that result in the error are:
PartsListStyle.AddColumn(kFileProperty, [Project], [Title], "Detail Name") PartsListStyle.AddColumn(kFileProperty, [Project], [Vendor], "MAT'L",,kTextCenter) PartsListStyle.AddColumn(kFileProperty, [Project], [Description], "Finish Size")
PartsListColumn.Reposition("Title", "Description") PartsListColumn.Reposition("Vendor", "Description")
The following is my code:
'This program will format the parts list to the company standard 'by choosing the correct columns and removing unnecessary ones, 'it will then place the parts list on the drawing. 'This specific program is for the Detail List. 'Setup for document and sheets Dim DrawingDoc As DrawingDocument DrawingDoc = ThisApplication.ActiveDocument Dim Sheet As Sheet Sheet = DrawingDoc.ActiveSheet Dim PartsList As PartsList = Sheet.PartsLists.Item(1) Dim PropSet As PropertySet Dim DrawingView = Sheet.DrawingViews(1) ' Set a reference to th sheet's border Dim Border As Border Border = Sheet.Border Dim PlacementPoint As Point2d If Not Border Is Nothing Then ' A border exists. The placement point ' is the top-right corner of the border. PlacementPoint = Border.RangeBox.MaxPoint Else ' There is no border. The placement point ' is the top-right corner of the sheet. PlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(Sheet.Width, Sheet.Height) End If 'Pre-Format Parts List 'Change Title PartsList.Title() = "Detail List" 'Show Title PartsList.ShowTitle = True 'Add Columns FMTID = PropSet.InternalName PartsListStyle.AddColumn(kFileProperty, [Project], [Title], "Detail Name") PartsListStyle.AddColumn(kFileProperty, [Project], [Vendor], "MAT'L",,kTextCenter) PartsListStyle.AddColumn(kFileProperty, [Project], [Description], "Finish Size") 'Remove Columns PartsList.PartsListColumns("Part Number").Remove 'Reposition PartsListColumn.Reposition("Title", "Description") PartsListColumn.Reposition("Vendor", "Description") 'Rename Columns ' Create the parts list. PartsList = Sheet.PartsLists.Add(DrawingView, PlacementPoint)
Solved! Go to Solution.