Adding Parameters to Assembly parts

Adding Parameters to Assembly parts

NachoShaw
Advisor Advisor
381 Views
1 Reply
Message 1 of 2

Adding Parameters to Assembly parts

NachoShaw
Advisor
Advisor

Hi

 

Is there a method available to loop through a top level assembly and add 3 parameters to each part? Ideally with 'export as parameter' checked. I can find anything and i havent done much on parameters through code.

 

 

Appreciate any help

 

Thanks

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


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

Anonymous
Not applicable

hi I have this code I have quickly added 2 more parameter in.

 

SyntaxEditor Code Snippet

'Define the open document
Dim oDoc As Document
oDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document

ModelName = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
'MessageBox.Show(ModelName)


If Not ThisApplication.ActiveDocument.DocumentType = kAssemblyDocumentObject Then 
    Return
End If

For Each docFile In oDoc.AllReferencedDocuments

    

    'open the indexed file
    'true opens the file normaly
    'false opens the file programatically without generating the graphics
    ThisApplication.Documents.Open(docFile.FullFileName, True)

    
    oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters



'creates a new "Numeric" parameter
myNewparam1 = "Parameter_Name1" ' replace Parameter_Name with your new name
myNewparamValue1 = "111" 'replace Parameter_value with your new value'convert for parameter in centremeters
myNewparamValue2 = myNewparamValue1 / 10
oParameter = oMyParameter.AddByValue(myNewparam1, myNewparamValue2, UnitsTypeEnum. kDefaultDisplayLengthUnits)

myNewparam2 = "Parameter_Name2" ' replace Parameter_Name with your new name
myNewparamValue2 = "222" 'replace Parameter_value with your new value'convert for parameter in centremeters
myNewparamValue3 = myNewparamValue2 / 10
oParameter = oMyParameter.AddByValue(myNewparam2, myNewparamValue3, UnitsTypeEnum. kDefaultDisplayLengthUnits)

myNewparam3 = "Parameter_Name3" ' replace Parameter_Name with your new name
myNewparamValue3 = "333" 'replace Parameter_value with your new value'convert for parameter in centremeters
myNewparamValue4 = myNewparamValue3 / 10
oParameter = oMyParameter.AddByValue(myNewparam3, myNewparamValue4, UnitsTypeEnum. kDefaultDisplayLengthUnits)


    docFile.Save
    docFile.Close
    
    
Next


iLogicVb.UpdateWhenDone = True


I also have this code that should tick the export box.
SyntaxEditor Code Snippet
Parameter.Param(docFName,"Parameter_Name1").ExposedAsProperty = True


0 Likes