Welcome back to the SmartCAMcnc blog ☺
Code Generator String expressions
If you are new to SmartCAM...
Here's a little background information just for you.
CAM engineers excel when they know how to use the Code Generator (let's refer to that as 'CG' ) and Customization ToolKit ( 'CTK' ) tools.
Sure, they are technical, but once they have grasped the fundamentals, they can achieve really good things using those tools.
We here at SmartCAMcnc have a deep-seated belief in the statement that 'the SmartCAM Code Generator and Customization tools are amongst the most open and flexible in the CAM software world.'
CTK work can comprise of a short and simple macro that is 'executed' by the SmartCAM engineer, or it can be the development of a whole suite of macros and can be enabled with custom user-interface panels.
A key element in both systems is variables: system- and user-defined. This blog post highlighted a new function that enhances string variable handling in the SmartCAM Code Generator.
We hope it has been helpful and technically interesting.
Talk CAM with us:
The SmartCAMcnc Team
The Code Generator String Processing function became available in v2019 SP1 of SmartCAM.
Over the years we have had many interesting discussions regarding strings and string handling in the SmartCAM Code Generator (CG) and Customization ToolKit (CTK).
In this post we will discuss the Macro String Expression function - #MSE - that can now be used in CG template (.cgt) files.
The SmartCAM macro mechanism has a whole load of string variable functions available, any of which can be incorporated within macro logic for all manner of purposes such as outputs and conditional-tests.
Examples of macro string functions are:
All macro string expressions can be used within the SmartCAM Code Generator Template file.
The syntax for accessing macro string processing functionality in a CG template file is a #MSE function embedded in a #EVAL string assignment:
If you are experienced with the SmartCAM Code Generator tools then you'll understand that stuff. But for the general benefit of all, let's break down that statement.
User Variables can be used within the SmartCAM Code Generator Template file.
They are declared in the @DECLARE section of the code generator template file; defining which type of data they will contain - string, integer or decimal type.
Since our example will return a string expression, it follows that our user variable would be declared as being of string type:
#STR #my_string
There is a User Variables topic in Learning SmartCAM, browse to Code Generation > Variables
#EVAL
To borrow the description from Learning SmartCAM , the #EVAL command is used to "Assign numeric and string words via numeric and string expressions."
Here is a simple example of the use of that command borrowed from Learning SmartCAM:
#EVAL( #diam = #radius * 2 )
using decimal variables in that case.
And so our example
#EVAL ( #my_string =#MSE( macro string expression ))
Assigns to a user string variable named #my_string the value returned by the #MSE function.
Here's a use case: A common request is to retrieve file names and paths such as those for the current CNC code file, or the current Shape File ( PM5 file ).
The last variable in our list of examples above, SHPFILE can be used to illustrate that type of case:
Macro functions can be found in the Customizing SmartCAM section in Learning SmartCAM
Functions that begin with S= in the documentation are string functions.
Go ahead and try it if you have a use case!
In this post we will discuss the Macro String Expression function - #MSE - that can now be used in CG template (.cgt) files.
The SmartCAM macro mechanism has a whole load of string variable functions available, any of which can be incorporated within macro logic for all manner of purposes such as outputs and conditional-tests.
Examples of macro string functions are:
GET_CNC_PATH | Returns the folder path where SmartCAM will write NC code files |
VERSION | Returns the current SmartCAM application's 'Header text' |
CODFILE | Returns the current CNC Code path and file name |
SHPFILE | Returns the current Process Model path and file name |
All macro string expressions can be used within the SmartCAM Code Generator Template file.
The syntax for accessing macro string processing functionality in a CG template file is a #MSE function embedded in a #EVAL string assignment:
#EVAL ( #my_string =#MSE( macro string expression ))
If you are experienced with the SmartCAM Code Generator tools then you'll understand that stuff. But for the general benefit of all, let's break down that statement.
User Variables can be used within the SmartCAM Code Generator Template file.
They are declared in the @DECLARE section of the code generator template file; defining which type of data they will contain - string, integer or decimal type.
Since our example will return a string expression, it follows that our user variable would be declared as being of string type:
#STR #my_string
There is a User Variables topic in Learning SmartCAM, browse to Code Generation > Variables
#EVAL
To borrow the description from Learning SmartCAM , the #EVAL command is used to "Assign numeric and string words via numeric and string expressions."
Here is a simple example of the use of that command borrowed from Learning SmartCAM:
#EVAL( #diam = #radius * 2 )
using decimal variables in that case.
And so our example
#EVAL ( #my_string =#MSE( macro string expression ))
Assigns to a user string variable named #my_string the value returned by the #MSE function.
Here's a use case: A common request is to retrieve file names and paths such as those for the current CNC code file, or the current Shape File ( PM5 file ).
The last variable in our list of examples above, SHPFILE can be used to illustrate that type of case:
#EVAL ( #my_string =#MSE( SHPFILE() ))
Macro functions can be found in the Customizing SmartCAM section in Learning SmartCAM
Functions that begin with S= in the documentation are string functions.
Go ahead and try it if you have a use case!
If you are new to SmartCAM...
Here's a little background information just for you.
CAM engineers excel when they know how to use the Code Generator (let's refer to that as 'CG' ) and Customization ToolKit ( 'CTK' ) tools.
Sure, they are technical, but once they have grasped the fundamentals, they can achieve really good things using those tools.
We here at SmartCAMcnc have a deep-seated belief in the statement that 'the SmartCAM Code Generator and Customization tools are amongst the most open and flexible in the CAM software world.'
CTK work can comprise of a short and simple macro that is 'executed' by the SmartCAM engineer, or it can be the development of a whole suite of macros and can be enabled with custom user-interface panels.
A key element in both systems is variables: system- and user-defined. This blog post highlighted a new function that enhances string variable handling in the SmartCAM Code Generator.
We hope it has been helpful and technically interesting.
Take care!
Talk CAM with us:
+1 (541) 344-4563
sales@smartcamcnc.com
The SmartCAMcnc Team
No comments:
Post a Comment