Create Parameters in Assembly with iLogic Rule

Create Parameters in Assembly with iLogic Rule

Anonymous
Not applicable
1,847 Views
2 Replies
Message 1 of 3

Create Parameters in Assembly with iLogic Rule

Anonymous
Not applicable

Hi,

 

I have one iLogic Rule which goes through every part in an assembly, extracts info, creates dxfs and exports BOMs along with other tasks

 

I am missing one element. I need to be able to create parameters in the subparts. I am able to create iProperties, but have not found anywhere how to create a new parameter in a subpart of the assembly in which the rule is running. Right now if those parameters are missing, I am using a Try - Catch to skip over tasks that would fail if they weren't present.

 

Any help is greatly appreciated.

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

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi heather5UNX9,

 

Something like this should work.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

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

 

 

Sub Main 

	Dim oValue As Double 
	dValue = 15 'value to push to each component

    Dim asmDoc As AssemblyDocument 
    asmDoc = ThisApplication.ActiveDocument 
    
    ' Iterate through all of the referenced documents
    Dim doc As Document 
    For Each doc In asmDoc.AllReferencedDocuments 
        'update the components 
        Call UpdateParameter(doc, dValue) 
    Next 
End Sub

Sub UpdateParameter(oDoc As Document, dValue As Double)    
    ' Get the user parameters collection. 
    Dim userParams As UserParameters 
    userParams = _  
   	oDoc.ComponentDefinition.Parameters.UserParameters 
	


    Dim param As Parameter 
    'set/create parameter
	Try
   	param = userParams.Item("TestParameter") 
	param.Value = dValue
	Catch  
   'The parameter doesn't exist so add it. 
    param = userParams.AddByExpression("TestParameter", _  
   	dValue, UnitsTypeEnum.kDefaultDisplayLengthUnits) 
    End Try	
	
End Sub

EESignature

Message 3 of 3

Anonymous
Not applicable

Thanks for the great help.

0 Likes