Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

stephlouv

Mechanical
Sep 10, 2013
125
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."
 
Replies continue below

Recommended for you

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.
 
Correcting the PTC/Creo code is not my question ;-)

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."
 
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
 
JohnRBaker said:
...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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor