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

Trim parameter from Trailing zeros

reggie.mostert
Contributor

Trim parameter from Trailing zeros

reggie.mostert
Contributor
Contributor

Hello,

 

I have the same problem as this guy:

https://forums.autodesk.com/t5/inventor-customization/trim-parameter-values-for-trailing-zeros/td-p/...

 

I have a code to round up parameters with the unit "mm" to be whole numbers. This is important in our assets for the BOM list in the end.  I use the following code:

Dim UserParams As UserParameters
UserParams = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters

For Each Item In UserParams
	 	If Item.Units = "mm" Then
			Item.Value = Ceil(Item.Value)
		End If
Next

 

This results in the parameters getting x,00000000 mm behind it. This is very confusing for the end user that uses the assets/parameters. How do i get rid of the zeroes?

0 Likes
Reply
Accepted solutions (2)
635 Views
3 Replies
Replies (3)

bradeneuropeArthur
Mentor
Mentor
Accepted solution

 

Dim UserParams As UserParameters
Dim p As Inventor.PartDocument = ThisApplication.ActiveDocument

UserParams = p.ComponentDefinition.Parameters.UserParameters
Dim item As Inventor.Parameter

'Ceil()
For Each item In UserParams
	 	If item.Units = "mm" Then
			
			'MsgBox (item.modelvalue)
			item.Value = Ceil(item.Value*10)/10
		End If
Next

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

dutt.thakar
Collaborator
Collaborator
Accepted solution

@reggie.mostert 

 

If you are using iLogic try the below code and see if this gives you the result you need.

 

Dim UserParams As UserParameters
UserParams = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters

For Each Item In UserParams
	 	If Item.Units = "mm" Then
			Dim x As Double = Ceil(Item.Value)
			 Parameter(Item.name) = x*10
		End If
Next

RuleParametersOutput
InventorVb.DocumentUpdate()

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes

reggie.mostert
Contributor
Contributor

Thanks guys! The code from @dutt.thakar worked fine. thanks again!

0 Likes