Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ILOGIC edit part parameter

2 REPLIES 2
Reply
Message 1 of 3
cstringer80
494 Views, 2 Replies

ILOGIC edit part parameter

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?

 

 

2 REPLIES 2
Message 2 of 3
jingyi.liu
in reply to: cstringer80

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


Jingyi Liu

Inventor Product Manager
Message 3 of 3
DeerSpotter
in reply to: cstringer80

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

 

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report