Dears,
I'm working in iPart/iAssembly Table. Please help me get the Column.Index for A(KG) - It's not fixed position, so that I wanna return where column.index for "A(KG)"
Thanks!
Solved! Go to Solution.
Dears,
I'm working in iPart/iAssembly Table. Please help me get the Column.Index for A(KG) - It's not fixed position, so that I wanna return where column.index for "A(KG)"
Thanks!
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by WCrihfield. Go to Solution.
Here is one way to get that information from an iPartFactory, but I haven't tested it yet.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oFactory As iPartFactory = Nothing
If oPDef.IsiPartFactory Then
oFactory = oPDef.iPartFactory
ElseIf oPDef.IsiPartMember Then
oFactory = oPDef.iPartMember.ParentFactory
Else
Exit Sub 'not an iPart
End If
Dim AKGCol As iPartTableColumn = Nothing
Dim oCols As iPartTableColumns = oFactory.TableColumns
For Each oCol As iPartTableColumn In oCols
If oCol.Heading = "A(KG)" Then
AKGCol = oCol
MsgBox("A(KG) Column Index = " & oCol.Index, , "A(KG) Column Index")
Exit For
End If
Next
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Here is one way to get that information from an iPartFactory, but I haven't tested it yet.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oFactory As iPartFactory = Nothing
If oPDef.IsiPartFactory Then
oFactory = oPDef.iPartFactory
ElseIf oPDef.IsiPartMember Then
oFactory = oPDef.iPartMember.ParentFactory
Else
Exit Sub 'not an iPart
End If
Dim AKGCol As iPartTableColumn = Nothing
Dim oCols As iPartTableColumns = oFactory.TableColumns
For Each oCol As iPartTableColumn In oCols
If oCol.Heading = "A(KG)" Then
AKGCol = oCol
MsgBox("A(KG) Column Index = " & oCol.Index, , "A(KG) Column Index")
Exit For
End If
Next
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Thanks for fast support! @WCrihfield
I got it.
Thanks for fast support! @WCrihfield
I got it.
Dear @WCrihfield
I got an error if column inserted by parameters/iproperties. It's only done with "Other" Could you please check it.
Thanks,
Dear @WCrihfield
I got an error if column inserted by parameters/iproperties. It's only done with "Other" Could you please check it.
Thanks,
Hi @ngnam1988. The iPart/iAssembly table, as well as the ModelStates table can be a little odd to navigate by the column heading text. For one thing, each column object actually 3 different properties for the 'heading' (DisplayHeading, FormattedHeading, Heading). And another thing is that the DisplayHeading & Heading properties can have different values. You will see what I mean if you open the iPart table as an Excel worksheet and look at the column headers there. The columns for iProperties will usually have extra text after the name of the property that indicates which PropertySet that property is stored in, and it uses the 'nickname' String (as used with the iProperties.Value snippet to specify the property set), instead of the true, full length name of the PropertySet object. You can try switching from using the regular Heading property value to using the DisplayHeading property value when checking the column headers to see if that makes it easier for you. That property's value may not contain the extra text.
If oCol.DisplayHeading = "A(KG)" Then
Wesley Crihfield
(Not an Autodesk Employee)
Hi @ngnam1988. The iPart/iAssembly table, as well as the ModelStates table can be a little odd to navigate by the column heading text. For one thing, each column object actually 3 different properties for the 'heading' (DisplayHeading, FormattedHeading, Heading). And another thing is that the DisplayHeading & Heading properties can have different values. You will see what I mean if you open the iPart table as an Excel worksheet and look at the column headers there. The columns for iProperties will usually have extra text after the name of the property that indicates which PropertySet that property is stored in, and it uses the 'nickname' String (as used with the iProperties.Value snippet to specify the property set), instead of the true, full length name of the PropertySet object. You can try switching from using the regular Heading property value to using the DisplayHeading property value when checking the column headers to see if that makes it easier for you. That property's value may not contain the extra text.
If oCol.DisplayHeading = "A(KG)" Then
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.