Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Column.Index in iPart/iAssembly Table

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ngnam1988
309 Views, 4 Replies

Get Column.Index in iPart/iAssembly Table

ngnam1988
Advocate
Advocate

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)"

ngnam1988_0-1691512732258.png

ngnam1988_1-1691512915323.png

 

Thanks!

0 Likes

Get Column.Index in iPart/iAssembly Table

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)"

ngnam1988_0-1691512732258.png

ngnam1988_1-1691512915323.png

 

Thanks!

Tags (3)
4 REPLIES 4
Message 2 of 5
WCrihfield
in reply to: ngnam1988

WCrihfield
Mentor
Mentor
Accepted 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

EESignature

(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

EESignature

(Not an Autodesk Employee)

Message 3 of 5
ngnam1988
in reply to: ngnam1988

ngnam1988
Advocate
Advocate

Thanks for fast support! @WCrihfield 
I got it.

0 Likes

Thanks for fast support! @WCrihfield 
I got it.

Message 4 of 5
ngnam1988
in reply to: WCrihfield

ngnam1988
Advocate
Advocate

Dear @WCrihfield 
I got an error if column inserted by parameters/iproperties. It's only done with "Other" Could you please check it.

ngnam1988_0-1691546837683.png

 

ngnam1988_0-1691547259575.png

 

Thanks,

0 Likes

Dear @WCrihfield 
I got an error if column inserted by parameters/iproperties. It's only done with "Other" Could you please check it.

ngnam1988_0-1691546837683.png

 

ngnam1988_0-1691547259575.png

 

Thanks,

Message 5 of 5
WCrihfield
in reply to: ngnam1988

WCrihfield
Mentor
Mentor
Accepted solution

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' (DisplayHeadingFormattedHeadingHeading).  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

EESignature

(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' (DisplayHeadingFormattedHeadingHeading).  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

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report