iLogic code to check if an iAssembly iTable contains a specific column

iLogic code to check if an iAssembly iTable contains a specific column

ober2558
Enthusiast Enthusiast
271 Views
1 Reply
Message 1 of 2

iLogic code to check if an iAssembly iTable contains a specific column

ober2558
Enthusiast
Enthusiast

I need a code snippet to be used in an assembly that determines if a specific custom column is present within an iAssembly member within the top-level assembly and performs an action if so.

0 Likes
272 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @ober2558.  If I am understanding your request correctly, then I believe the following code example should get you most of the way to your goal.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
	If oOcc.IsiAssemblyMember Then
		Dim iAsmMem As iAssemblyMember = oOcc.Definition.iAssemblyMember
		Dim oCols As iAssemblyTableColumns = iAsmMem.ParentFactory.TableColumns
		For Each oCol As iAssemblyTableColumn In oCols
			'If oCol.ReferencedDataType = iComponentColumnTypeEnum.kFilePropertyColumn Then
			If oCol.DisplayHeading = "YourSearchTerm" Then
				'<<<< Put Your Action Code Here >>>>
			End If
		Next 'oCol
	End If
Next 'oOcc

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)

0 Likes