Inventor General Discussion

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

ILOGIC edit part parameter

167 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: 120
Registered: ‎08-28-2007
Message 2 of 3 (147 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: 189
Registered: ‎04-01-2013
Message 3 of 3 (37 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube