Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: dibujocad

Here is a version of that same rule that will dig down through all levels under the purchased sub assemblies to set them all to Purchased, just in case that is what you really wanted.

Sub Main()
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	oOccs = oAsmDoc.ComponentDefinition.Occurrences
	For Each oOcc As ComponentOccurrence In oOccs
		'If it's not an Assembly, don't process it
		If oOcc.DefinitionDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Continue For
		'If it's not Purchased, don't process it
		If oOcc.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure Then Continue For
		StepDown(oOcc.Definition.Occurrences)
	Next
End Sub

Sub StepDown(oComps As ComponentOccurrences)
	For Each oComp As ComponentOccurrence In oComps
		If oComp.BOMStructure <> BOMStructureEnum.kPurchasedBOMStructure Then
			oComp.BOMStructure =BOMStructureEnum.kPurchasedBOMStructure
		End If
		If oComp.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			StepDown(oComp.Definition.Occurrences)
		End If
	Next
End Sub

Wesley Crihfield

EESignature

(Not an Autodesk Employee)