How to insert part number column in drawing part lists with API?

How to insert part number column in drawing part lists with API?

Anonymous
Not applicable
846 Views
3 Replies
Message 1 of 4

How to insert part number column in drawing part lists with API?

Anonymous
Not applicable

I have to update a large amount of drawings to new styles. I already have code that updates the title block, but when updating the parts list I have not found any working way of inserting a "part number" column.

 

I have successfully inserted other columns, but my attempts at part number will either throw an exception or show nothing:

 

' access the old, obsolete parts list style for assemblies
Dim AssemblyStyle = Doc.StylesManager.PartsListStyles("Lista de piezas(Plano Conjuntos)")

' re-create all its columns
AssemblyStyle.RemoveAllColumns()
AssemblyStyle.AddColumn(Inventor.PropertyTypeEnum.kItemPartsListProperty, , "Item", "ID", 6.4 / 10, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter)
AssemblyStyle.AddColumn(Inventor.PropertyTypeEnum.kQuantityPartsListProperty, , "Quantity", "Uds", 6.8 / 10, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter)
' ... (MISSING: PART NUMBER)
AssemblyStyle.AddColumn(Inventor.PropertyTypeEnum.kCustomProperty, , PropNames.Codigo, "Código", 29.9 / 10, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter)
AssemblyStyle.AddColumn(Inventor.PropertyTypeEnum.kCustomProperty, , PropNames.TipoMat, "Material", 64.7 / 10, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter, Inventor.HorizontalTextAlignmentEnum.kAlignTextLeft)
AssemblyStyle.AddColumn(Inventor.PropertyTypeEnum.kCustomProperty, , PropNames.Peso, "Kg/Ud", 12.2 / 10, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter, Inventor.HorizontalTextAlignmentEnum.kAlignTextRight)

' re-create the parts list in first sheet, to make it update its style
Dim PartsListPosition = Doc.Sheets(1).PartsLists(1).Position
Dim PartsListView = Doc.Sheets(1).PartsLists(1).ReferencedDocumentDescriptor.ReferencedDocument
Doc.Sheets(1).PartsLists(1).Delete()
Doc.Sheets(1).PartsLists.Add(PartsListView, PartsListPosition, Inventor.PartsListLevelEnum.kStructuredAllLevels, Inventor.NumberingSchemeEnum.kNumericNumbering, 1)

 

It is easy to insert part number manually, but for the API I cannot find the proper use of PartsList.AddColumn method documented anywhere.

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

t_remal
Autodesk
Autodesk
Accepted solution

Hello,

I think you can add the column using kFileProperty like this:

 

AssemblyStyle.AddColumn(Inventor.PropertyTypeEnum.kFileProperty, "{32853F0F-3444-11d1-9E93-0060B03C1CA6}", Inventor.PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties, "Part Number", 6.8, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter, Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter)

 

Regards,

Lubomir

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you t_remal. By the way, how did you figure that out?

I haven't seen any documentation on this.

 

By trial and error I had been able to do it in this other way, obtaining IDs from the drawn document.

They may both be equivalent

 

              

Dim PropertySetID = Part.PropertySets("Design Tracking Properties").InternalName
Dim PropertyID = Part.PropertySets("Design Tracking Properties").Item("Part Number").PropId
AssemblyPartsListStyle.AddColumn
(
Inventor.PropertyTypeEnum.kFileProperty,
PropertySetsID,
PropertyID,
"Part Number",
65.0 / 10,
Inventor.HorizontalTextAlignmentEnum.kAlignTextCenter,
Inventor.HorizontalTextAlignmentEnum.kAlignTextLeft
)

 

0 Likes
Message 4 of 4

t_remal
Autodesk
Autodesk

Hello,

 

It's in the Inventor API manual (admapi_19_0.chm):

Inventor API User's Manual -> Custom Data -> Working with iProperties

 

Your code seems to do the same thing.

 

Lubomir

0 Likes