×
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

NX8.0 : How to script expressions as PTC/Creo doing ?

NX8.0 : How to script expressions as PTC/Creo doing ?

NX8.0 : How to script expressions as PTC/Creo doing ?

(OP)
Hello there,

Is there a way in NX8 to script expressions values as the PTC Creo "Relations" doing ?
I found that more conveniant if you have a lot of IF conditions.

Ex, in Creo :
if idtalf_xwf == 0
angif_xwf=30
cd1wxf=epf_wf*tan(angif_xwf)
idtalf_xwf=2*epf_wf+2
talf1_wf=talf_wf
angef_wf=angef_vwf
else
cd1wxf=epf_wf*tan(angif_xwf)
cd2wxf=(idtalf_xwf-idf_wf)/2
talf1_wf=talf_wf+cd2wxf
angef_wf=angef_xwf
endif

So, using only one IF condition, you can set values for several variables.
And these values can be also changed later in the script if another condition ask it. Usefull.

In NX8, it's the all way round, for each variable ou have to set a IF statement.
It's much more coding. And having a cascade of IF for each parameter is confusing.

Thank you

Stéphane

"My english is bad ? That's why i'am french."

RE: NX8.0 : How to script expressions as PTC/Creo doing ?

Let me think about that one for a bit, but I think you have a mistake in your example code from PTC/Creo. I don't know where you got the "idtalf_xwf=2*epf_wf+2" in the first part of the expression. I would think that it would be something like "cd2wxf=something" instead. Besides, if you leave the "idtalf_xwf=2*epf_wf+2" there it appears to be trying to change the value of the IF statment's conditional value INSIDE the IF statement, which I would be surprised is allowed.

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: NX8.0 : How to script expressions as PTC/Creo doing ?

(OP)
Correcting the PTC/Creo code is not my question winky smile

I assume it is working as it's in use here since 1999.
If Creo interpreting the code, this can be done.
It doesn't disturb me if a IF changes his own condition.

Maybe you'll prefer this extract :


if join_nflg == "rtj" | join_nflg == "RTJ" & nrtj_nflg ~= 0
D16=krtj_nflg
D12=lrtj_nflg
D7=c_nflg
D10=ywn_nflg
haut_nflg=lrtj_nflg+ywn_nflg
haut_cone=ywn_nflg-c_nflg-lgcol_fac
else
D16=rrf_nflg
D12=lrf_nflg
if clas_nflg < 400
D7=(c_nflg-lrf_nflg)
D10=(ywn_nflg-lrf_nflg)
haut_nflg=ywn_nflg
haut_cone=ywn_nflg-c_nflg-lgcol_fac
else
D7=c_nflg
D10=ywn_nflg
haut_nflg=lrf_nflg+ywn_nflg
haut_cone=ywn_nflg-c_nflg-lgcol_fac
endif
endif

Become this in NX :
D7=if (join_nflg=="rtj"|join_nflg=="RTJ"&nrtj_nflg!=0) (c_nflg) else (if (clas_nflg<400) (c_nflg-lrf_nflg) else (c_nflg))
D10=if (join_nflg=="rtj"|join_nflg=="RTJ"&nrtj_nflg!=0) (ywn_nflg) else (if (clas_nflg<400) (ywn_nflg-lrf_nflg) else (ywn_nflg))
Etc .. Etc ....

"My english is bad ? That's why i'am french."

RE: NX8.0 : How to script expressions as PTC/Creo doing ?

Try doing the scripting in NX's journal language instead of just expressions.

You aren't really comparing apples in functionality between NX expressions and Creo Relations.
While conceptually they do the same function, Creo relations are a subset of Pro/Program which is why they are more robust. You could get that coding in a GRIP program, but you now need journaling.


"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli

RE: NX8.0 : How to script expressions as PTC/Creo doing ?

Quote (JohnRBaker)

...it appears to be trying to change the value of the IF statment's conditional value INSIDE the IF statement, which I would be surprised is allowed.

This is valid (and useful) in all the languages I have experience with. Now if you are changing the 'counter' variable within a loop construct; it is technically allowed, but can get you in trouble.

www.nxjournaling.com

RE: NX8.0 : How to script expressions as PTC/Creo doing ?

I knew about changing the counter (I've done that myself in GRIP and yes, you can mess things up pretty easily) but I had not heard of anyone changing the conditional value, which just seems even more problematic.

BTW, I'm thinking that perhaps this could be reduced in complexity with NX if you used a 'List' expression to collect and categorize the formulas and then have a single, simple IF statement to get the proper 'nth' value so as to extract the appropriate records from the 'List' expression.

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.

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