×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Modulus operator buggy?

Modulus operator buggy?

Modulus operator buggy?

(OP)
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

RE: Modulus operator buggy?

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.

RE: Modulus operator buggy?

(OP)
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 

RE: Modulus operator buggy?

(OP)
Sorry, the part is not empty, but it is just a sketch and I encountered the problem first when the part was empty..

RE: Modulus operator buggy?

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.

RE: Modulus operator buggy?

(OP)
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 ...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources