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 to Change all parameters with value 5,000000 mm to 1,5 mm

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
CoolenEng
505 Views, 5 Replies

iLogic to Change all parameters with value 5,000000 mm to 1,5 mm

Hello,

 

I need a iLogic VBA to Change all parameters from a part with the value 5,000000 mm to 1,5 mm

 

Can anybody help me?

5 REPLIES 5
Message 2 of 6

Hi techniek,

 

Here is a quick example iLogic rule that should work for you:

 

 

' Get the active document, this assumes
' that a part document is active in Inventor.
Dim oPartDoc As Inventor.PartDocument
oPartDoc = ThisApplication.ActiveDocument

' Get the Parameters collection
Dim oParams As Parameters
oParams = oPartDoc.ComponentDefinition.Parameters
    
' Iterate through the Parameters collection to obtain
' information about the Parameters
Dim iNumParams As Long
For iNumParams = 1 To oParams.Count
If oParams.Item(iNumParams).Value = 5 mm Then 
oParams.Item(iNumParams).Value = 1.5 mm
End If
Next

iLogicVb.UpdateWhenDone = True

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

Message 3 of 6

Hi Curtis_Waguespack,

 

Thanks for your reaction!

 

I copied it in a new iLogic rule but when i run it, it doesnt work.

 

The parameter doesn't change.

 

Best regards,

Rob Coolen

Message 4 of 6

Hi techniek,

 

So it might be due to the decimal format of the parameter value that I used (rather than the comma format) . Give this a try and report back if it still doesn't work:

 

oExistingValue = InputBox("Enter value to change FROM:", "iLogic", "5")
oNewValue = InputBox("Enter value to change TO:", "iLogic", "1.5")

' Get the active document, this assumes
' that a part document is active in Inventor.
Dim oPartDoc As Inventor.PartDocument
oPartDoc = ThisApplication.ActiveDocument

' Get the Parameters collection
Dim oParams As Parameters
oParams = oPartDoc.ComponentDefinition.Parameters

Dim dValue1 as double
dValue1 = oExistingValue * 0.1
dValue2 = oNewValue * 0.1
Dim strOut1 As String
strOut = CStr(dValue1)
Dim strOut2 As String
strOut = CStr(dValue2)
    
' Iterate through the Parameters collection to obtain
' information about the Parameters
Dim iNumParams As Long
For iNumParams = 1 To oParams.Count
If oParams.Item(iNumParams).Value = dValue1  Then
oParams.Item(iNumParams).Value = dValue2
End If
Next

iLogicVb.UpdateWhenDone = True


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

Message 5 of 6

Works perfect, i only had to change the 1.5 to 1,5 to get the correct value.

 

Thanks!!!

Message 6 of 6

This saved me a lot of time!

 

thank you

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

Post to forums  

Autodesk Design & Make Report