Inventor General Discussion

Inventor General Discussion

Reply
Mentor
jddickson
Posts: 182
Registered: ‎10-07-2011
Message 1 of 2 (626 Views)
Accepted Solution

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

626 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)

 

 

'Rounding OD AND THICKNESS

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

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)

 

'Rounding OD AND THICKNESS

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)

Mentor
jddickson
Posts: 182
Registered: ‎10-07-2011
Message 2 of 2 (596 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)

 

'Rounding OD AND THICKNESS

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)

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.