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?
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
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
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
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
Works perfect, i only had to change the 1.5 to 1,5 to get the correct value.
Thanks!!!