Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modulus operator buggy?

Status
Not open for further replies.

icetea73

New member
Apr 10, 2013
53
Is there some trick when using the modulus operator "%" in expressions?
It seems that it doesn't work consistently - sometimes I get an syntax error and other times it just works just for the same expression.
When entering the expression as soon as % is entered the auto-completion stops working. This is all inside the expression editor. Using the mod() function works in the same context by the way...

For example: "(1%level)*(stock_dia/2+gap)" gives an syntax error while "mod(1,level)*(stock_dia/2+gap)" just works.


I'm using NX9.0.1.3
 
Replies continue below

Recommended for you

Can you provide an example where the '%' operator works? It doesn't have to be a part (although that would be better), just the expression text should be enough as long as we know what all the referenced expressions in the formula represent.

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.
 
This is an export of the expressions (I added the comments after the export). The actual part is still empty.
It seems that it never works if the value has units and it stops working when the expression gets more complicated.

Code:
[mm]extension=40
[mm]gap=1
[mm]grid=10
[mm]length=100
level=3
[mm]p3=length/2
[mm]p4=extension-stock_skip_len
[mm]p5=stock_skip_len
[mm]p6=(level-1)*grid+2*stock_skip_len
[mm]p7=extension+level*grid
[mm]stock_dia=2.8
[mm]stock_skip_len=mod(1,level)*(stock_dia/2+gap)
test_1=(1%level)+3 // must be a constant to avoid syntax error
test_flag=1%level // must be a constant to avoid syntax error
test_x=(1%level)*(stock_dia/2+gap) // always syntax error, even when defined as constant
 
Sorry, the part is not empty, but it is just a sketch and I encountered the problem first when the part was empty..
 
Have you tried to change the last expression to:

test_x=test_flag*(stock_dia/2+gap)

As for the 'constant' issue, I'm not surprised ay all.

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.
 
Thank you John. Sure, that works. There are enough workarounds. The simplest one is just avoiding it and using mod() instead. The documentation doesn't mention anything special about % but the obvious fact that the operands are treated as integers. Just another bug from a users point of view.
NX sometimes (lately more often than not) makes me [curse] ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor