Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

convert a unit parameter

dessinumwb
Explorer

convert a unit parameter

dessinumwb
Explorer
Explorer

Hi,

i'm using Iventor 2023,

Need an Ilogic to convert a user parameter, in to mm and vis versa.

It's almost working but something wrong some where! 

 

the LG parameter is the input lenght and LGM is the result.

 

My need is when i enter a lenght  5270 mm (LG) , i need to see result like 207.48 in (LGM)

or in i enter a lenght 207.48 in (LG), i need to see result like 5270 mm (LGM)

 

here's the code i trying to make it work

Dim oParams As Parameters
oParams = ThisDoc.Document.ComponentDefinition​.Parameters

 Dim oParamName As Parameter
oParamName = oParams.Item("LGM") 

 
If LG = kInchLengthUnits Then
      oParamName.Units = "mm"
  ElseIf LG = kMillimeterLengthUnits Then
      oParamName.Units = "in"
End If

 ThisDoc.Document.Update

Thank you

0 Likes
Reply
Accepted solutions (1)
373 Views
2 Replies
Replies (2)

dalton98
Collaborator
Collaborator
Accepted solution

edit

you would need to setup an event trigger for 'Any User Parameter Change'

Dim oParams As Parameters
oParams = ThisDoc.Document.ComponentDefinition​.Parameters

Dim oLG As Inventor.Parameter = oParams.Item("LG")
Dim oLGM As Inventor.Parameter = oParams.Item("LGM")

'fix LG units to input units
'oLG.Units = Right(oLG.Expression, 2)
oLG.Units = Right(oLG.Expression, oLG.Expression.Length - InStrRev(oLG.Expression, " "))
oLGM.Value = oLG.Value

Select Case oLG.Units
	Case "in", "ft", "mil", "nauticalmile"
		oLG.Units = "in"
		oLGM.Units = "mm"
	Case "mm", "cm", "m", "micron"
		oLG.Units = "mm"
		oLGM.Units = "in"
End Select

 

0 Likes

dessinumwb
Explorer
Explorer

Thank you, it's working perfectly

0 Likes