Round down to nearest whole, odd number
Round down to nearest whole, odd number
(OP)
I am driving a sketch using a perimeter constraint tied to an expression which is tied to an assocative perimeter measurement which is the result of another sketch which is also driven by expressions.
The goal is input expressions for measurements. The first sketch yields a visual model to determine the aesthetics. This then drives the second sketch but with the rounding I need to "tweak" the perimeters of some curves to follow mathematical rules.
The two sketches are working.
Now, I need to change the perimeter constraints to not just be an expression tied to the perimeter measurement, but to take that measurement, divide by a constant, round down to the nearest whole, odd integer and then multiply that back by the constant again to yield a new "adjusted" perimeter.
The closest I have done to this before now is interpart linking with rounding up and unit conversion.
please help!
The goal is input expressions for measurements. The first sketch yields a visual model to determine the aesthetics. This then drives the second sketch but with the rounding I need to "tweak" the perimeters of some curves to follow mathematical rules.
The two sketches are working.
Now, I need to change the perimeter constraints to not just be an expression tied to the perimeter measurement, but to take that measurement, divide by a constant, round down to the nearest whole, odd integer and then multiply that back by the constant again to yield a new "adjusted" perimeter.
The closest I have done to this before now is interpart linking with rounding up and unit conversion.
please help!
NX 8.0.1.5





RE: Round down to nearest whole, odd number
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Round down to nearest whole, odd number
I will investigate further in the am. Thanks
NX 9.0.1.3
RE: Round down to nearest whole, odd number
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Round down to nearest whole, odd number
10.26456911 is the current result of the X_LENGTH_PERIMETER. I know I can use floor to round down similar to using ceiling to round up as I have in the past. I have also rounded with units before as well (thanks to your other posts). So in this case I will show you what I want to do mathematically.
First divide the Perimeters by my Crystal Spacing Expression (.45). In the first case 10.26456911/.45 = 22.810153577777777777777777777778
Second, I need to round to the nearest odd number. In this case I would round up to 23. If the perimeter was 21.99 or less I would want to round down to 21. So I guess now that I have written this out, I want to round to the nearest odd integer.
Third, I want to multiply the nearest odd integer, in this case 23, times the Spacing again (.45). 23*.45 = 10.35
Fourth, I need to set my Perimeter constraint equal to this to drive my second sketch.
I see no reason why we cannot do all of this with a single equation where the current perimeter constraint pulls the Perimeter Expression Tied to the Length Measurement yielded from the first sketch. I would then just repeat for the second perimeter.
Thanks in advance!
NX 9.0.1.3
RE: Round down to nearest whole, odd number
CODE --> expression
The above expression code checks the value of expression "t1" and gives the closest odd integer. The only wrinkle is if the value of "t1" is an even integer; in this case it subtracts 1 from "t1", but you may want to change that to add 1.
www.nxjournaling.com
RE: Round down to nearest whole, odd number
You will need to change the "p" numbers.
p101 is the rounded down, odd, whole number that you want
p100=22.810153577777777777777777777778
p101=if (p100-(((floor(p100/2))*2))>=(1))(((floor(p100/2))*2)+1)else(((floor(p100/2))*2)-1)
RE: Round down to nearest whole, odd number
10.26456911/.45 = 22.810153577777777777777777777778
RE: Round down to nearest whole, odd number
I can create a situation with certain input expressions that drive the first sketch that create an underconstrained first sketch warning or even make the arcs flip inside out but it does not break and the driven sketch still works. This is a problem within the sketch itself due to wanting to control too many things. This could be fixed but I would need a bunch of complicated geometric formula constraints. For now, it is doing what I want (with limitations). If I need to go further I am not sure how I would do so due to Non Disclosure, etc. Thanks all.
NX 9.0.1.3
RE: Round down to nearest whole, odd number
RE: Round down to nearest whole, odd number
NX 9.0.1.3
RE: Round down to nearest whole, odd number
So you would create a new expression and make it equal to: (floor)p123 if I remember the syntax correctly.
The same would be true for the opposite direction, rounding up, would be the (ceiling) command.
RE: Round down to nearest whole, odd number
the trick was to make it an odd number.
RE: Round down to nearest whole, odd number
So, you will see in the attached screen shot, when the X input is 18 it works fine.
NX 9.0.1.3
RE: Round down to nearest whole, odd number
NX 9.0.1.3
RE: Round down to nearest whole, odd number
CODE
What's currently happening is you are only performing the multiplication if the "else" portion of the IF test is run. Adding the parentheses will take whatever answer comes from the rounding calc and use that in the multiplication operation.
www.nxjournaling.com
RE: Round down to nearest whole, odd number
NX 9.0.1.3