Add a column to a partslist

Add a column to a partslist

Anonymous
Not applicable
1,190 Views
4 Replies
Message 1 of 5

Add a column to a partslist

Anonymous
Not applicable
I need to add a custom column to a parts list
and have it display as the last column.

oPartsList.PartsListColumns.Add (kCustomProperty)

This code runs, but nothing happens...no error...no column...

Any suggestions?

Thanks,
Victor
0 Likes
1,191 Views
4 Replies
Replies (4)
Message 2 of 5

SonnyN
Archived Account
Hi Victor,

As per online help it requires PropID arg when you use kCustomProp.

Try something similar to the following code:

Sub AddCustomProperty()
' Assuming the current active document is Drawing
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet

' Assuming there is at least one partslist on the activesheet
Dim oPL As PartsList
Set oPL = oSheet.PartsLists(1)

' Create a custom PropertySet & Property
Dim oPropSet As PropertySet
Set oPropSet = oDrawDoc.PropertySets.Add("Custom BOM Props")

Dim oProp As Property, vPropVal As Variant
Set oProp = oPropSet.Add("Yes", "Purchased")

' Create the custom column
Dim oPLCol As PartsListColumn
Set oPLCol = oPL.PartsListColumns.Add(kCustomProperty, , oProp.PropId)

oPLCol.Title = "Purchased"
End Sub

Thanks.

-Sonny N
(Autodesk)
0 Likes
Message 3 of 5

Anonymous
Not applicable
Your sample allows me to add custom properties to a parts list. I need 3 additional columns & the related parameter values (dimensions that I defined in each of my parts). Using your code, I can add the 3 extra columns I need, but can't figure out how to assign the parameter values I need (and have stored for the parts) to them.
*** Code below ***

' Assuming there is at least one partslist on the activesheet
Dim oPL As PartsList
oPL = oSheet.PartsLists(1)

' Create a custom PropertySet & Property
Dim oPropSet As PropertySet
oPropSet = oDrawDoc.PropertySets.Add("plist_columns")

Dim oProp1 As Inventor.Property
Dim oProp2 As Inventor.Property
Dim oProp3 As Inventor.Property
Dim vPropVal As Object

oProp1 = oPropSet.Add("", "Length1")
oProp2 = oPropSet.Add("", "Width1")
oProp3 = oPropSet.Add("", "Thickness1")

' Create the custom column
Dim oPLCol As PartsListColumn
oPLCol = oPL.PartsListColumns.Add(PropertyTypeEnum.kCustomProperty, , oProp1.PropId)
oPLCol.Title = "Length1"
oPLCol = oPL.PartsListColumns.Add(PropertyTypeEnum.kCustomProperty, , oProp2.PropId)
oPLCol.Title = "Width1"
oPLCol = oPL.PartsListColumns.Add(PropertyTypeEnum.kCustomProperty, , oProp3.PropId)
oPLCol.Title = "Thickness1"
0 Likes
Message 4 of 5

Anonymous
Not applicable

I know it's an old thread, but have you then solved the problem on how to add a new custom property and read the properties values?

0 Likes
Message 5 of 5

xiaodong_liang
Autodesk Support
Autodesk Support

Hi dbrizio,

 

I think the PartsListColumns.Add is still the method to add column of custom property. Did you meet any specific problem? Could you provide a demo code?

0 Likes