Inventor General

Posts: 180
Registered: ‎10-07-2011
Message 1 of 2 (539 Views)
Accepted Solution

Rounding to the 3rd decimal place. (iLogic help)

539 Views, 1 Replies
03-25-2013 09:01 AM

I’m getting close to what I need but I’m falling a little short. I’m trying to make everything show to the 3rd decimal place.  My code is rounding everything to the 3rd decimal place but not always showing decimal to the 3rd place.


My Code so Far:


'Rounding Strap

inc = .0625 ' rounding increment ( .125, .25, .5, etc)

Strap = (WearPlateIR + WearPlateOR)*3.14

Strap_Rounded = Round(Round(Round(Strap,4) / inc) * inc,3)




Round_OD = WearPlateOR*2

Round_THICK = WearPlateOR-WearPlateIR


FINISHED_OD = Round(Round(Round(Round_OD,4) / inc) * inc,3)

FINISHED_THICK = Round(Round(Round(Round_THICK,4) / inc) * inc,3)



'TF Bom (Description)

iProperties.Value("Custom", "TF BOM")="=SLEEVE " & FINISHED_OD & " OD x " & FINISHED_THICK & " WALL x <WearPlateWidth> LG, STRAP=" & Strap_Rounded & " (CUT INTO TWO HALVES)"



What I’m getting Example:

SHELL 20.75 OD x 0.375 WALL x 9.000 LG, STRAP=64 (CUT INTO TWO HALVES)


What I want Example:

SHELL 20.750 OD x 0.375 WALL x 9.000 LG, STRAP=64.000 (CUT INTO TWO HALVES)


I know I could go thru the user parameters and do it that way (it would have been easier that way but there are several hundred already done). The easiest thing for me to do now is paste some code into each one and be done with them.


I would appreciate any help that you might be able to give me.


Thank you

Posts: 180
Registered: ‎10-07-2011
Message 2 of 2 (509 Views)

Re: Rounding to the 3rd decimal place. (iLogic help)

03-25-2013 12:43 PM in reply to: jddickson

I figured it out. If anyone would like to know how I did it (doesn’t mean that it’s right) the fixed code is below.


New Code:  


'Rounding inc

inc = .0625 ' rounding increment ( .125, .25, .5, etc)



FINISHED_THICK = Format(Round(Round(Round(Thickness,4) / inc) * inc,3),".000")

FINISHED_WIDTH = Format(Round(Round(Round(Width,4) / inc) * inc,3),".000")

FINISHED_LENGTH = Format(Round(Round(Round(Length,4) / inc) * inc,3),".000")


'TF Bom (Description)

iProperties.Value("Custom", "TF BOM")="=PLATE "& FINISHED_THICK &" X "& FINISHED_WIDTH &" X "& FINISHED_LENGTH &""


'Rounding Mass

iProperties.Value("Custom", "Mass")=Round(iProperties.Mass)

iProperties.Value("Custom", "Masskg")=Round(iProperties.Mass*0.45359237)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community

Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor