iLogic Code to Delete Specific Parameter in all Parts Within Assembly

iLogic Code to Delete Specific Parameter in all Parts Within Assembly

Cadderman
Enthusiast Enthusiast
72 Views
2 Replies
Message 1 of 3

iLogic Code to Delete Specific Parameter in all Parts Within Assembly

Cadderman
Enthusiast
Enthusiast

Hi all,

 

I'm not particularly good at producing iLogic codes - I need what I think should be quite a simple code...

 

I need to delete the parameter "Thickness" in all components within an assembly. 

 

Any help would be greatly appreciated.

 

0 Likes
73 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant

Hi @Cadderman, something like this should work. Hope that helps, Curtis

Sub Main

	Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences

	Call TraverseAssembly(oOccs)

End Sub

Function TraverseAssembly(oOccs As ComponentOccurrences)

	Dim oOcc As ComponentOccurrence
	For Each oOcc In oOccs
		If oOcc.Suppressed = True Then Continue For
		'get the document from the occurrence
		Dim oDoc = oOcc.Definition.Document

		Try
			oDoc.ComponentDefinition.Parameters.Item("Thickness").Delete
			Logger.Info(oOcc.Name & " parameter deleted")
		Catch 
			Logger.Info(oOcc.Name & " could not find or delete parameter")
		End Try

		'if assembly loop back up and step down into it's occurrences
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Call TraverseAssembly(oOcc.SubOccurrences)
		Else 
			' handle stuff for just parts here if needed
		End If
	Next

End Function

 

EESignature

0 Likes
Message 3 of 3

Cadderman
Enthusiast
Enthusiast

Perfect, thanks @Curtis_Waguespack ! Much appreciated