Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic rule for each part in the assembly to change partt paramenter

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
achmidt
9596 Views, 6 Replies

ilogic rule for each part in the assembly to change partt paramenter

Hello,

I`m looking for the iLogic code that can change one parameter (user defined) for each (ipt) part in assembly (iam)

The one below doesn`t work. Any help is appreciated.

 

Sub Main
  Dim oApp As Inventor.Application =  ThisApplication
  Dim oAssy As Inventor.AssemblyDocument = oApp.ActiveDocument
  For Each oSubDoc as Inventor.Document In oAssy.AllReferencedDocuments
  On Error Resume Next
   Parameter(oSubDoc, "FH") = 15.26
  Next
   End Sub

 Thanks,

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen
6 REPLIES 6
Message 2 of 7
YuhanZhang
in reply to: achmidt

I think you can use it like below:

 

Parameter("Part1:1", "d0") = 1.2


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 7
achmidt
in reply to: YuhanZhang

Rocky,

That what I had in my code :

I thought it suppose to take every ipt in my iam as oSubDoc find the FH parameter and change it to 15.26.

Am I doing something wrong?

 

Parameter(oSubDoc, "FH") = 15.26

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen
Message 4 of 7
Curtis_Waguespack
in reply to: achmidt

Hi achmidt,

 

Here are two examples that will work. The first looks at the occurences by name the second looks at the actual files by file name:

 

' 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 occurrences
Dim 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, "FH") = 15.26
InventorVb.DocumentUpdate()
Else
End If
Next

 

 

'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
Parameter(docFName, "FH") = 15.26
InventorVb.DocumentUpdate()
Next

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 5 of 7
achmidt
in reply to: Curtis_Waguespack

Curtis,

 

Thanks a lot, that what I was looking for!

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen
Message 6 of 7
ChristinaForest
in reply to: achmidt

Hi Curtis 🙂

 

It's possible to put a try and catch in the rule to verify if parameter exist???

 

Thnaks for your help 🙂

Message 7 of 7

is it possible to re write it to make all part numbers in sub assemblies and parts equal to filename minus extensions. 

i've tried several different ilogic rules, posted different places, and none seems work, or i get a error.

 

i want the rule to run on assembly level, and not embeded in the part template.  

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

Post to forums  

Autodesk Design & Make Report