Round off to no decimals without comma

Round off to no decimals without comma

sso_enerdry
Explorer Explorer
1,056 Views
5 Replies
Message 1 of 6

Round off to no decimals without comma

sso_enerdry
Explorer
Explorer

I have a short Ilogic, that rounds of my mass on my parts/assemblies as follows:

 

If iProperties.Mass<0.1 Then
iProperties.Value("custom", "Rounded_Mass") = Round(iProperties.Mass, 3)
ElseIf iProperties.Mass<1 Then
iProperties.Value("custom", "Rounded_Mass") = Round(iProperties.Mass, 2)
ElseIf iProperties.Mass<10 Then
iProperties.Value("custom", "Rounded_Mass") = Round(iProperties.Mass, 1)
Else If iProperties.Mass>10 Then
iProperties.Value("custom", "Rounded_Mass") = Round(iProperties.Mass, 0)
InventorVb.DocumentUpdate()

End If

 

The last Else If - when the mass is over 10 kg. I want it to show the mass without decimals.
This works, but it keeps writing e.g. "165," instead of "165"
How do I remove the comma?

 

Thanks in advance.

0 Likes
Accepted solutions (1)
1,057 Views
5 Replies
Replies (5)
Message 2 of 6

blandb
Mentor
Mentor

I copied your code into a part in 2019 and I dont get the comma.

Autodesk Certified Professional
0 Likes
Message 3 of 6

marcin_otręba
Advisor
Advisor
Accepted solution

try cstr(Round(iProperties.Mass, 0)).Replace(",", "")

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 4 of 6

bradeneuropeArthur
Mentor
Mentor

@sso_enerdry

 

What version of inventor are you working with?

did you choose the Rounded_Mass as number or as text?

for me the code works fine with as number...

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 5 of 6

sso_enerdry
Explorer
Explorer

Hi Marcin

Your solution seems to work.

I also tried this, for the last line:

Properties.Value("custom", "Rounded_Mass") = Int(iProperties.Mass)

Which seems to solve the problem as well.

 

Thanks 

Soeren

0 Likes
Message 6 of 6

sso_enerdry
Explorer
Explorer

hi Bradeneurope
I'm running Inventor 2018.

I've solved the problem by turning the rounded value into an integer.

It is a little funny though, that I couldn't get my first try to work

 

but thanks anyway

 

br

Soeren

 

0 Likes