Welcome back once again to the SmartCAMcnc blog ☺
Code Generator String expressions
Technical stuff: bring it on. I'm not going to mess about with an introduction this time: as someone who thrives on the technical I'm heading straight to the interesting technical content of this post.
The Interesting Bit
If you have yet to discover SmartCAM
Here's a little background information, just for you.
CAM engineers who use SmartCAM know that the Code Generator ( let's refer to that as 'The CG' ) and Customization ToolKit ( 'The CTK' ) tools excel.
Sure, they are technical, but once you have grasped the fundamentals you can achieve really good things using those tools.
I've said it before and no doubt will say it again - because 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.
I hope it has been helpful and as technically interesting as it was for me.
Talk CAM with us. We're at:
The SmartCAMcnc Team
Technical stuff: bring it on. I'm not going to mess about with an introduction this time: as someone who thrives on the technical I'm heading straight to the interesting technical content of this post.
The Interesting Bit
A new Code Generator String Processing function became
available in the latest release of SmartCAM, Version 2019 SP1.
Over the years we have had many interesting discussions regarding strings and string handling in the SmartCAM Code Generator ( CG ) and Customization ToolKit ( CTK ).
We want to tell you about a new 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 now 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."
I'll sneak in here a simple example of the use of that command, again 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 SmartCAM Customization Guide, navigate to Automating SmartCAM with macros > Macro functions
Functions that begin with S= in the documentation are string functions.
We want to let you know that the function is still in a beta state, but felt it was worth including in the SP1 release. At the time of writing, our testing has found that the EL_NAME() function is the only function not working correctly.
Please go ahead and try it if you have a use case!
We want to tell you about a new 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 now 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."
I'll sneak in here a simple example of the use of that command, again 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 SmartCAM Customization Guide, navigate to Automating SmartCAM with macros > Macro functions
Functions that begin with S= in the documentation are string functions.
We want to let you know that the function is still in a beta state, but felt it was worth including in the SP1 release. At the time of writing, our testing has found that the EL_NAME() function is the only function not working correctly.
Please go ahead and try it if you have a use case!
If you have yet to discover SmartCAM
Here's a little background information, just for you.
CAM engineers who use SmartCAM know that the Code Generator ( let's refer to that as 'The CG' ) and Customization ToolKit ( 'The CTK' ) tools excel.
Sure, they are technical, but once you have grasped the fundamentals you can achieve really good things using those tools.
I've said it before and no doubt will say it again - because 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.
I hope it has been helpful and as technically interesting as it was for me.
Take care.
Have a great day / evening / weekend.
Talk CAM with us. We're at:
+1 (541) 344-4563
sales@smartcamcnc.com
The SmartCAMcnc Team
No comments:
Post a Comment