Inventor General Discussion

Inventor General Discussion

Reply
Distinguished Contributor
cstringer80
Posts: 111
Registered: ‎10-03-2008
Message 1 of 3 (184 Views)

ILOGIC edit part parameter

184 Views, 2 Replies
06-25-2013 02:22 PM

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?

 

 

Employee
jingyi.liu
Posts: 121
Registered: ‎08-28-2007
Message 2 of 3 (164 Views)

Re: ILOGIC edit part parameter

06-26-2013 12:20 AM 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
Inventor Professional 2015

Jingyi Liu
Quality Assurance Team
Autodesk
Distinguished Contributor
m.teleguz1
Posts: 193
Registered: ‎04-01-2013
Message 3 of 3 (54 Views)

Re: ILOGIC edit part parameter

05-01-2014 08:48 AM 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.
..........................................................................................................................
Privacy warning: Since I live in a country that has traded liberty for the illusion of security, all of your posts to me are being monitored and saved by the United States Government.


See My LinkedIn Profile
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.