Trim parameter from Trailing zeros

Trim parameter from Trailing zeros

reggie.mostert
Contributor Contributor
720 Views
3 Replies
Message 1 of 4

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
Accepted solutions (2)
721 Views
3 Replies
Replies (3)
Message 2 of 4

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 & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 3 of 4

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
Message 4 of 4

reggie.mostert
Contributor
Contributor

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

0 Likes