iLogic Rule for deploying an userdefined Multivalue Parameter to all parts of an assembly

iLogic Rule for deploying an userdefined Multivalue Parameter to all parts of an assembly

stigler
Advocate Advocate
622 Views
2 Replies
Message 1 of 3

iLogic Rule for deploying an userdefined Multivalue Parameter to all parts of an assembly

stigler
Advocate
Advocate

Hello, good evening!

 

As I am a beginner in iLogic I have another question to you:

 

I have an iLogic rule for parts to create an userdefined Multivalue Parameter in the active part. I would like to use this rule in an assembly for all the parts referenced in the active assembly.

Dim oPartDoc As Document
oPartDoc = ThisDoc.Document

If oPartDoc.DocumentType = kPartDocumentObject Then

	Dim oPartCompDef As PartComponentDefinition
		oPartCompDef = oPartDoc.ComponentDefinition
		
Dim oParams As Parameters
		oParams=oPartCompDef.Parameters
				
		Dim oUserParams As UserParameters
		oUserParams=oParams.UserParameters       
		
		Dim oAwesomeParameter As Parameter                     
				
		Try
			otester = oUserParams.Item("SI_Z1")
			Catch

oInsulationType = oUserParams.AddByValue("SI_Z1", " ", kTextUnits) 
MultiValue.SetList("SI_Z1", "g", "kg", "l", "m2",  "m3",  "mm",  "PC",  "STK",  "t")
			End Try
            End If

Parameter.Param("SI_Z1").ExposedAsProperty = False
Parameter.Param("SI_Z1").IsKey = False

I have tried a lot of different ideas to create a loop but it didn't work!

 

It would be great if you could give me a solution for this problem.

 

Thank You very much for help in previous

0 Likes
Accepted solutions (1)
623 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @stigler

 

Welcome to the world of iLogic. I think this example will work for you.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Sub Main

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

	Call TraverseAssembly(oOccs)

	InventorVb.DocumentUpdate()

End Sub

Function TraverseAssembly(oOccs As ComponentOccurrences)

	Dim oOcc As ComponentOccurrence
	For Each oOcc In oOccs

		oDoc = oOcc.Definition.Document

		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			Call TraverseAssembly(oOcc.SubOccurrences)
		Else 'parts
			Call SetList(oOcc)
		End If
	Next

End Function

Sub SetList(oOcc As ComponentOccurrence)

	Dim oPartDoc As PartDocument
	oPartDoc = oOcc.Definition.Document

	Dim oParams As Parameters
	oParams = oPartDoc.ComponentDefinition.Parameters

	Dim oUserParams As UserParameters
	oUserParams = oParams.UserParameters

	oParamName = "SI_Z1"
	sDefault = "g"

	Try
		oParam = oUserParams.Item(oParamName)
	Catch
		oParam = oUserParams.AddByValue(oParamName, sDefault, kTextUnits)
	End Try

	MultiValue.SetListInComponent(oOcc.Name, oParamName, sDefault, "kg", "l", "m2", "m3", "mm", "PC", "STK", "t")

End Sub

 

0 Likes
Message 3 of 3

stigler
Advocate
Advocate

Hello Curtis_Waguespack thank you for your help!

It's running perfectly!

 

Greetings from Austria

 

Stigler