Problem with variables in pcl-script
Problem with variables in pcl-script
(OP)
Hello everyone,
once again pcl is kicking my butt ;).
I try to build a pcl-script and use global variables. In the main script I try to access a variable ("elsize_") in an if-statement:
Unfortunately this doesn't seem to work. Patran reports the error:
But, if I use the command to create the mesh seed on the specified curves outside the if-statement the whole thing works.
What is the problem there? What do I have to change? I don't thick pcl doesn't allow the usage of variable inside of if-statements.
Best regards
Martin
once again pcl is kicking my butt ;).
I try to build a pcl-script and use global variables. In the main script I try to access a variable ("elsize_") in an if-statement:
CODE
GLOBAL REAL elsize_ = 20.0
GLOBAL LOGICAL test_ = TRUE
IF (test == true_) THEN
mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
$? YESFORALL 2001017
END IF
GLOBAL LOGICAL test_ = TRUE
IF (test == true_) THEN
mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
$? YESFORALL 2001017
END IF
Unfortunately this doesn't seem to work. Patran reports the error:
CODE
mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
$# (PCL) Missing operand to expression
$# Line is "mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`,
$# 0. )"
$# Character is "`"
$# (PCL) Missing right parenthesis
$# Line is "mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`,
$# 0. )"
$# Extra information: mesh_seed_create
$# (PCL) Missing operand to expression
$# Line is "mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`,
$# 0. )"
$# Character is "`"
$# (PCL) Missing right parenthesis
$# Line is "mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`,
$# 0. )"
$# Extra information: mesh_seed_create
But, if I use the command to create the mesh seed on the specified curves outside the if-statement the whole thing works.
What is the problem there? What do I have to change? I don't thick pcl doesn't allow the usage of variable inside of if-statements.
Best regards
Martin





RE: Problem with variables in pcl-script
CODE
GLOBAL LOGICAL test_ = TRUE
IF (test_ == TRUE) THEN
mesh_seed_create( "Curve 1000001:1000030", 2, 0, 0., `elsize_`, 0. )
$? YESFORALL 2001017
END IF
RE: Problem with variables in pcl-script
Is this code snippet part of a Function/Class?
Or, are you running as session file or with !!INPUT?
Looping and control structures don't work in a session file (or read with !!INPUT). They need to be in a FUNCTION.
Here's a way to solve the problem. Note: Globals can't be declared inside functions. Also, the back-quotes are NOT used with variables inside a function.
CODE
REAL elsize_ = 20.0
LOGICAL test_ = TRUE
IF (test_ == TRUE ) THEN
ui_write ("Test is True")
mesh_seed_create( "Curve 1:4", 2, 0, 0., elsize_, 0. )
$? YESFORALL 2001017
END IF
END FUNCTION /* eng_tips_test */
Save this snippet as eng_tips_test.pcl
You run this by entering this on Patran's command line:
!! INPUT eng_tips_test.pcl
eng_tips_test()
If you really want GLOBAL variables, you need a slightly different method.
CODE
/* declare, but don't initialize variables */
REAL elsize_
LOGICAL test_
IF (test_ == TRUE ) THEN
ui_write ("Test is True")
mesh_seed_create( "Curve 1:4", 2, 0, 0., elsize_, 0. )
$? YESFORALL 2001017
END IF
END FUNCTION /* eng_tips_test2 */
Save this snippet as eng_tips_test2.pcl
You run this by entering this on Patran's command line:
!! INPUT eng_tips_test2.pcl
GLOBAL REAL elsize_ = 20.0
GLOBAL LOGICAL test_ = TRUE
eng_tips_test2()
Ta-da! Done! :)
RE: Problem with variables in pcl-script
as you thought, I tried to access my snipplet in a session file.