Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

parameter rounding up to nearest fractional part of inch

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
cadman777
28863 Views, 19 Replies

parameter rounding up to nearest fractional part of inch

IV2010Suite

Can someone tell me how to round a number up to the nearest fractional part of inch, say 32nds or 16ths or 8ths?

I can't get it to do more than the nearest whole number.

Is this a limitation?
If so, are there add-ons or other ways to do it?

Thanks ... Chris H

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
19 REPLIES 19
Message 2 of 20
cwhetten
in reply to: cadman777

It might depend on what you need the parameter for.  If you just want to display it in a drawing or BOM, then you can export the parameter and change the custom property format to display in architectural to the nearest 1/4", 1/8", 1/32" etc.

 

If you actually need to use it for a dimension or in a formula, I might have to think about it a minute to see if it is possible.

 

You could do it through excel easily enough... Hmm...  I'll get back to you.

 

-cwhetten

 

Message 3 of 20
cwhetten
in reply to: cadman777

Ok, here's a way to do it.  The attached part RoundTest1.ipt has a parameter called Length whose value is not a nice fraction of an inch.  The feature uses the Length parameter rounded to the nearest 1/32".  This is controlled by an equation in the feature parameter d0:

 

round(Length * 32 ul / 1 in) * 1 in / 32 ul

 

All of the funky unit stuff is necessary because the round() function expects a unitless argument and returns a unitless value, but the Length and d0 parameters are in inches.

 

If you want to be able to change the round-off value easily (say from 1/32" to 1/8"), you could create a parameter for this round value and use that.  The attached part RoundTest2.ipt uses this scheme.  The formula for d0 is much simpler, too:

 

round(Length / RoundValue) * RoundValue

 

Hope this helps.

 

-cwhetten

 

IV2010 Professional SP3
Build 551 Subscription Advantage Pack
Windows 7 Pro 64-bit

Dell T3500, Intel Xeon Duo 2.40 GHz, 6 GB RAM

NVIDIA Quadro FX 1800, 768 MB
Driver Ver: 197.85
Dual Monitors, 1280x1024

Message 4 of 20
cadman777
in reply to: cwhetten

cwhetten,

Very nice! Thanks for this simple solution.

One more question:

Can you please explain to me how that 'math' works?
I believe I'm ignorant of how the IV 'round' function works, or maybe I'm just forgetting some math function, which may be why I was unable to come up with your solution in the first place.

If I can understand the HOW of what you did, it may go a long way in understanding how other things work in the parameters dialogue.

Better yet, if you can direct me to a white paper that explains the way the various functions work, that would be even better.

Thanks! ... Chris

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 5 of 20
cwhetten
in reply to: cadman777

Your welcome.

 

The math works like this.  If you want a number that is rounded to the nearest 1/32" then you are looking for a fraction that is a whole number divided by 32, like 121/32 or 8/32 or whatever.  If you multiply the number by 32, then you are finding the top part of that fraction, like 121 or 8.

 

Now, chances are your number isn't a nice multiple of 1/32, like 3.77.  When you multiply 3.77 by 32, you get 120.64, which isn't a whole number.  Essentially, this is telling you that 3.77" is 120.64 thirty-seconds of an inch.  To round your number to the nearest 1/32", you need to round 120.64 to the nearest whole number.

 

This is where the round() function comes into play.  In this case, rounding 120.64 yields 121.  So 3.77" rounded to the nearest 1/32" is equal to 121 thirty-seconds of an inch.

 

At this point, you must divide 121 by 32 to get the decimal value of your rounded number.  121/32 is equal to 3.78125, or 3 and 25/32.  Therefore, 3.77" rounded to the nearest 1/32" is 3 25/32".

 

As for how the round() function works, the closest thing I have to any kind of official info on functions in Inventor is in the help documentation.  Look in the help contents under Autodesk Inventor > Design Optimization > Parameters in Models > Quick Reference Tab > Use formulas and equations > Functions.  This info isn't very specific about the functions, but from what I have gathered through experience, the floor() function rounds a number DOWN to the nearest whole number, the ceil() function rounds UP to the nearest whole number, and round() simply rounds to the nearest whole number.

 

For instance:

floor(3.77) = 3      floor(3.3) = 3

ceil(3.77) = 4       ceil(3.3) = 4

round(3.77) = 4    round(3.3) = 3

 

I hope this helps.

 

-cwhetten

 

Message 6 of 20
cadman777
in reply to: cadman777

Makes sense.

Thanks for the simple explanation.

I must admit, that sounds like some simple math manipulation that I may have known back in my h.s. days.

But these days ... "if you dont' use it, you lose it."

Thanks again! ... Chris

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 7 of 20
A.Benedict
in reply to: cadman777

I am having problems getting the accepted solution to this inquiry to work... when I attempt (Round(.280 * 16 ul / 1 in) * 1 in / 16 ul) I expect the solution to come back as 5/16" rounded up.  It does not.  It comes back as .25 whis is obviously less then the original .280 and not rounded UP.  I need to take a pipe schedule decimal and round it UP to 16ths, then add to it.  Can anyone assist?  Thanks in advance

Message 8 of 20
SBix26
in reply to: A.Benedict

Read cwhetton's second post where he shows the use of round, ceil and floor functions.  Round rounds to nearest, ceil rounds up, floor rounds down.  You want the ceil function instead of the round function.

Sam B
Inventor 2012 Certified Professional

Inventor Professional 2015 SP1
Windows 7 Enterprise 64-bit, SP1
HP EliteBook 8770w; 8 GB RAM; Core™ i7-3720QM 2.60 GHz; Quadro K4000M

Message 9 of 20

The OP asked to Round Up and thats exactly what i need

 

Round.Ceil rounds to the next higher integer not decimal so it wont work for fractions of an inch.

 

Has anyone figuer it out?

Chris Hildebran
VDC Software Development
IBEW 48 Wireman
ISA CCST 1
JH Kelly, LLC
Message 10 of 20

Read @cwhetten's first post (post #3) where he illustrates how to round to a specific fractional number (1/32" in the example), and use the ceil function instead of round.


Sam B
Inventor Pro 2019.1 | Windows 7 SP1
LinkedIn

Message 11 of 20
mark5DGVX
in reply to: cadman777

quick question, how can i round of the number down wards?  i only work with metric so this story above does not make sense ad all to me. 

 

the answer of my formula is 3.4 so i want to keep 3 whole united which i want to use in my pattern.

mark5DGVX_0-1645769908471.png

 

Message 12 of 20
mark5DGVX
in reply to: mark5DGVX

i managed to find something on the great web, but inventor is screwing me over.

 

mark5DGVX_1-1645770988203.png

first of al measure fuction does not update/work properly but that besides.

if i use my calculator 3069/900 = 3.41

when i use the floor function it should be 3.

answer given by inventor = 30 😞 

Message 13 of 20
mark5DGVX
in reply to: mark5DGVX

mark5DGVX_0-1645771523860.png

en this is before adding floor

answer = 3.41

 

i have to have this since measure function wont update but that's oke if it works.

Message 14 of 20
mark5DGVX
in reply to: cadman777

adding a 3th layer also does not work: 

mark5DGVX_0-1645771850961.png

inventor lacks my basic needs sometimes. 

 

Message 15 of 20
mark5DGVX
in reply to: cadman777

mark5DGVX_1-1645772422360.png

 

now i have made a parameter that is always going to be 900mm coming from a part in my assembly.

 

next i did:

 

pijpstukmaatgroot/pijpstuklengte 

 

pijpstukmaatgroot = 3069

pijpstuk lengte is 900

= 3.41 not 34. for god sake.

its 3.41 and i want to use floor in front of it to end up with the number 3.

 

Message 16 of 20
cadman777
in reply to: mark5DGVX

Sorry I can't read your Russian Parameters.

To accomplish what you want, you specify the UNITS to round.
That's the key.

Example:

floor (d0 * 10 ul / 1 mm) * 1 mm / 10 ul

Notes:

- 'd0' is the parameter you want to round

- floor rounds down, ceil rounds up, round goes to closest up/down.

- 10 is 1 place to right of decimal, 100 is 2 places, etc.

Here's a link where I got that.

Sergio uses the same 'math' that I use.

I learned this many years ago from a math guy in this forum.

Too bad I forget his name, so can't give him credit!

Like my father used to say: "Give credit where credit is due!"

And he wasn't talking about greedy financiers, evil bankers or the mafia!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 17 of 20
SBix26
in reply to: mark5DGVX

Adding to what @cadman777 wrote:  

 

When equations appear in red in your parameters dialog, it means they're not valid, so you can't trust the results.  They usually are invalid because of units problems but might also be due to mismatched parentheses, or function names or variables that don't exist.  In this case it is because floor (and ceil and round) is a unitless function.  You have to remove the linear unit (mm) from the function argument and then add it back after the function, as @cadman777 showed you in his post.


Sam B

Inventor Pro 2022.2.2 | Windows 10 Home 21H2
autodesk-expert-elite-member-logo-1line-rgb-black.png

Message 18 of 20
mark5DGVX
in reply to: cadman777

got it , changed to Ul.

 

not russian not oekraines. its dutch.

Message 19 of 20
cadman777
in reply to: mark5DGVX

Dutch.

I should'a looked closer.

Had a few occasions to translate Dutch drawings in the distant past...the hard way!

One more thing: had I read this thread from the beginning, I would'a seen that this is the thread that I was talking about where @cwhetten explains the math behind rounding. THIS is that thread...duh!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 20 of 20
hansDPQMN
in reply to: mark5DGVX

je moet unitloos rekenen

hansDPQMN_0-1687529603861.png

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report