Community
Is it possible with iLogic code to set a parameter in a bunch of parts equal to another paramter?
I want some iLogic code that will go into my pipe parts and make the PL param = D2.
Doable?
Hi
You can try below code to your assembly file, it will check occurrences in your assembly and modify the value of PL and make it equal to D2.
I saw your previous post on Pipe Length, please notice some type of Pipe, like thread pipe, its default length parameter refer to D3 other than D2.
' Set a reference To the Assembly Component definintion. ' This assumes an assembly document is open.Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Iterate through all of the occurrencesDim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences 'check for and skip virtual components '(in case a virtual component trips things up)If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then Parameter.Quiet = True Parameter(oOccurrence.Name, "PL") = Parameter(oOccurrence.Name, "d2") InventorVb.DocumentUpdate() Else End If Next
since no solution was posted this is a much cleaner and faster approach:
'Define the open document Dim openDoc As Document openDoc = ThisDoc.Document 'Look at all of the files referenced in the open document Dim docFile As Document For Each docFile In openDoc.AllReferencedDocuments 'format file name Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) Parameter.Quiet = True 'example start: Parameter(docFName, "L1") = Parameter("Length_1") Parameter(docFName, "L2") = Parameter("Length_2") Parameter(docFName, "L3") = Parameter("Length_3") Parameter(docFName, "ST1") = Parameter("Shell_1") Parameter(docFName, "ST2") = Parameter("Shell_2") Parameter(docFName, "ST3") = Parameter("Shell_3") Parameter(docFName, "Dia_1") = Parameter("Diameter_1") Parameter(docFName, "Dia_2") = Parameter("Diameter_2") Parameter(docFName, "Dia_3") = Parameter("Diameter_3") 'example end: InventorVb.DocumentUpdate() Next