Local and Mac Variables Defined
A MacVar Operation is the same as a LocalVar Operation. However, a Macro can have multiple MacVar definitions located anywhere in the Macro sequence. The LocalVar always appears just after the Panel Operation in a fixed position in the Macro sequence. All definitions below apply to Local Variables and Mac Variables.
A Variable is defined by a Name and a Formula. The Result is determined by the evaluation of the Formula.
Parameter Definitions:
•Name - Ascii name of the Variable. The name of the variable cannot have spaces or dashes. Some variable names are protected and cannot be used. The Parametric Macro Builder will warn if the variable name chosen is protected.
•Formula - an expression that defines the Variable's result
•Result - the evaluated result of the Formula
•Condition - a logical formula that evaluates to True or False. True and False or represented as 1 or 0 in the grid. If True, the Variable will be evaluated. If False, the Variable will be skipped, not evaluated and not available for reference by any Macro Operations.
•Status - used only by the LocalVar Operation. Options or Tagged and Dynamic. These options are used by Router-CIM Automation suite.
•Notes - text description of the Variable.
Variables are evaluated in the order of position in the Macro sequence. All defined variables are available to all following Operations.
Variable Naming Conventions
•Variable names can not be a LISP function name, a CAL function name or any Protected Variable name defined by the Macro Builder
•Characters used to define a variable name must begin with a letter and can not contain special character like <blank>=/<>[]{}()+-*~^
Variable Formula Restriction
•A Variable's formula can only reference previously defined Variable names or XDIM, YDIM and ZDIM Panel variables.
•A Variable's formula can be a CAL math expression, a Lisp Logical expression or a complex Lisp expression with a numeric result.
You can use the same variable name as long as a condition is used in order to only have one of the named instances available at one time.
Here is an example of using the same variable name with a condition statement.
Reference the AutoCAD Programmers Reference manual for Lisp function description.
Reference the CAL command in the AutoCAD User Help for CAL function names and expression formats.
Variable Interface
Variables are presented in a grid format. The currently selected variable is indicated by an arrow in the numbered selector, contents are bold type and the grid row appears in a highlighted color. To Edit an existing variable simply select the Name or Formula field and make the desired edit. Selecting the Result field will not cause an edit. The Result field is the results determined by evaluating the Formula. This occurs after the acceptance of the edits. To Add a New variable select the Name field next to the last un-numbered row that has an * as its selector. Enter the name, press TAB key and enter the formula. The Name and Formula fields support the Windows Clipboard. Right Click on the field and the Clipboard menu will display. |
Grid Row Editing
|
Right Click on the Grid with display the Edit Menu. The Edit menu provides for several different methods to edit the row sequence. These methods are available or not available depending prior edits. When an Edit method is not correct for the selected row, the method will be "grayed out" and not selectable. These Edit methods are not to be confused with the Windows Clipboard functions. The changing of the grid row is controlled by the Macro Builder using its own internal functions. Even though the methods are similar to Clipboard functions these Edit methods are not Clipboard functions. You can not Copy rows and paste them into another application. All Edit methods support multiple selection of rows. Multiple selection is performed by hold the Shift or Ctrl key while selecting multiple operations. NOTE: If a variable name is used in a formula this dependence restricts the removing or deleting the variable name. Options to Remove or Delete the variable will be disabled as shown on the left.
|
Grid Row Editing Methods
•Cut - will place the selected rows into a temporary buffer and remove the selected rows from the grid. These rows can be insert back into the grid at another row location.
•Copy - will make a copy of the selected rows and store those rows in a temporary buffer to be inserted back into the grid at another row location.
•Insert cut or copied variable - if the temporary buffer contains operations that have been copied or removed, this will insert the collected rows at the ( before ) current selected row.
•Insert Blank variable - Inserts a Blank variable above the selected variable
•Delete - will delete the selected rows from the grid permanently. A Yes/No question will be asked to validate that you want to delete. No Undo is available.
•Cancel Pending Operation - if a variable is currently in 'Cut' or 'Copy', it will release it from the Parametric Macro Builder memory
Grid Cell Editing
After changing a cell content press the TAB key to accept the edit and go to the next cell in the row or press the ENTER key to accept the edit and go to the next row.
Formula Formats
There are three formula formats available:
•Numeric - a CAL formatted math expression that evaluates to a numeric result.
•Logical - a LISP formatted logical expression that evaluates to True or False
•Lisp - a complex LISP expression that evaluates to a numeric result.
Numeric
CAL evaluates expressions according to standard mathematical rules of precedence:
•Expressions in parentheses first, starting with the innermost set
•Operators in standard order: exponents first, multiplication and division second, and addition and subtraction last
•Operators of equal precedence from left to right
Numeric Expressions
Numeric expressions are real integer numbers and functions combined with the operators in the following table.
Numeric Operators |
|
Operator |
Operation |
( ) |
Groups expressions |
^ |
Indicates exponentiation |
* , / |
Multiplies, divides |
+, - |
Adds, subtracts |
SIN, COS, TAN, ASIN, ACOS, ATAN |
Common Geometric Functions |
The following are examples of numeric expressions:
3
3 + 0.6
(5.8^2) + PI
Reference the CAL Help in AutoCAD for a complete list of functions available.
Besides common numeric operators, you can reference the 'Common Variable Equation Expressions' below for ways to compare expressions.
IMPORTANT NOTE: A CAL expression's structure is Operand followed by Operator followed by Operand; standard mathematical expressions. A CAL expression DOES NOT START WITH A = SIGN IN ITS DEFINITION. Examples: A + B or (A + B). NO EQUAL SIGN.
Logical
A Logical statement can be formatted in two forms:
•= A > B - formatted starting with a = sign followed by an Operand, then the Operator, ending with a Operand
•=(> A B) - formatted as a Lisp expression. Starts with a = sign to indicate a Lisp expression. See AutoCAD Developer Help, AutoLisp functions.
A logical must start with a = sign. After the = sign either format can be used.
A Logical variable formula can be formatted as a Lisp expression. The structure starts with a left parenthesis, followed by an logical operator, followed by two operands to be compared, then closing with a right parenthesis. Each separated by a space. Example: =(> 1 0) evaluated to True. 1 is greater than 0. Lisp expressions are in the form of prefix notation ( postfix notation ) that places the operators to the left of their operands.
An example of a Logical variable formula using a Lisp expression: =(IF (> VALUE1 25) T (IF (= VALUE2 10) T NIL)) This example reads as IF VALUE1 > 25 THEN TRUE ELSE IF VALUE2 = 10 THEN TRUE ELSE FALSE. This expression will evaluate as True or False depending on the conditions in the expression. The expression can be as complex as needed up to 1024 characters.
IMPORTANT NOTE: A LISP expression MUST START WITH A = ( equal sign ). This is required to indicate to the formula field that this is Lisp.
Lisp
A complex variable formula is formatted as a Lisp expression. Any lisp expression with the use of lisp functions can be used. See AutoCAD Developer Help, AutoLisp functions.
An example of a complex variable formula using a Lisp expression: =(IF (> VALUE1 25) 25 (IF (= VALUE2 10) 5 75)) This example reads as IF VALUE1 > 25 THEN 25 ELSE IF VALUE2 = 10 THEN 5 ELSE 75. This expression will evaluate as 25, 5 or 75 depending on the conditions in the expression. The expression can be as complex as needed up to 1024 characters.
IMPORTANT NOTE: A LISP expression MUST START WITH A = ( equal sign ). This is required to indicate to the formula field that this is Lisp.
Character limit for a LISP expression is 1024 characters.
The last evaluated expression must result in a numeric result.
A Special Variable named LISP
If you name a variable with the special name of LISP a lisp expression in the formula field is required. This Lisp expression should not start with a = sign and must start with a right parenthesis (. Any legal Lisp expression can be used and does not have to have the last evaluation be a numeric result. The Result in the Macro builder will always be zero. The LISP variable name can not be reference by any other formula in the Macro. It is a dummy name and should not be considered a Variable name that can be reference by other formulas. Example: (dofunc 5.0). This is a Lisp expression that calls a predefined function named dofunc and passes to the function one parameter 5.0.
Condition Format
The condition format is the same as the Conditional Builder. See the Condition Builder in the Editor Interface section of this Help. An example of a condition is A > B. Notice it starts with an Operand followed by a logical Operator and ending with an Operand. No parentheses are used.
Multiple Condition Format
In order to evaluate a multiple condition format, multiple local variables MAY need to be created. This multiple condition format is common when defining a range set.
For example, if you want to have an operation that needs to be used when the XDIM is greater then 12 but less then or equal to an XDIM of 20, this would be a simple set up in the Local Variables section:
The XDIM is currently set to 10. You can see that the variable RANGE_A1 is 0 (False) but RANGE_A2 is 1 (True). The multiple condition is being checked by the variable RANGE_A_T which is 0 (False).
Another option for a single line formula would be =(IF(> XDIM 12) (IF(<= XDIM 20) 1 0)). This result would be NUMERIC as a 1 or 0.
Under the Operation, you will then create a Condition statement to react to the variable RANGE_A_T as shown in the image. In this case with an XDIM of 10, the condition evaluated as False.
When the XDIM is set to 15. You can see that the variable RANGE_A1 is now 1 (True) and RANGE_A2 is 1 (True). The multiple condition is being checked by the variable RANGE_A_T which now evaluates as 1 (True).
In this case with an XDIM of 15, the condition evaluated as True turning on the operation.
Status Options
Status options include blank ( the default ), TAGGED and DYNAMIC. These status options TAGGED and DYNAMIC are used by Router-CIM Automation Suite.
Reference the Router-CIM Automation Suite documentation for a complete understanding of using variables in automation jobs.
TAGGED
Tagged variables are variables that can be carried to the Router-CIM Automation program with a macro. By using Tagged Variables, you would not have to go back to the Parametric Macro Builder to change the variables value.
When would I use the Tagged Variables feature and what type of variables would go into it?
For example, let's say we designed a basic door in the Macro Builder, but we want the ability to quickly change the dimensions of the door on a regular basis. By assigning variable names and proper formulas to the individual features of the door, we can quickly change the size of the door features in Router-CIM Automation Suite without going back into the Macro Builder.
Selecting the TAGGED option of Variable status in the local variables grid will cause both the name and the value of the chosen variable to be displayed in the Router-CIM Automation Suite interface when preparing automation jobs. Only these Tagged Local variables are available during Router-CIM Automation Suite.
Example:
The Variables TOEKICK_X, TOEKICK_Y, SHELVES and NUMBER_HOLES are given the values of 5, 4, 3, and 2, respectively and they are also designated as tagged. The macro has accomplished the following:
•These "tagged" variables will appear in the Router-CIM Automation Job window when this particular macro is opened in Router-CIM Automation Suite. You are able to make edits to these variables in Router-CIM Automation Suite and have them saved for the particular job you are working on. The changes to the variables will only be reflected in the current job and not in the original macro.
•These variables are used when creating formulas which define the parts of the macro. By having variables in the formula opposed to strictly numbers allows the freedom of changing the macro dimensions in the Router-CIM Automation Suite Job Editor.
•Rather than creating a whole new macro from scratch, you can now change the Local Variables values associated with an existing macro, copy and save it under a new name, and have this reflected in the new macro
DYNAMIC
When a Router-CIM Automation Suite job is built there is an overriding set of variables that stay active for each Macro that is used. Unlike Local and Global variables, these variables can be used in the Macro dimensions of the Router-CIM Automation Suite interface. When a Dynamic variable is created there will be a scan done of all the Macros in a job so that all the Dynamic variables previously created are made available. Dynamic variables are not limited to variable definitions in the Macros.
Dynamic Variables are defined in two locations when using the Router-CIM Automation Suite:
•In the Local Variables in the Macro Builder - similar to tagging a variable by specifying the variable as a Dynamic in the Macro.
•In the Dynamic Variables list in the Router-CIM Automation Suite Job Editor.
Reference the Dynamic Variable documentation in the Router-CIM Help.
Notes
Text that describes the variable. Optional.
Validation Process
All variable definitions go through a strict validation process when Accept is selected. It is important to know how this process works. The basic rules are simple:
•A Variable Name can not be a protected name, CAL function or LISP function name
•A Variable Formula that uses variable names must use names that have been previously defined in the evaluation sequence
•Variable names and formulas can not contain special characters
Any violation of these rules will result in a validation error and corrections have to be made prior to a successful Accept.
Important Note: If you use complex Lisp statements the validation process is ignored. Complex Lisp statements can not be validated by the validation process. Care must be taken when using Lisp statements. A bad Macro can be developed which can cause an evaluation error. Reference the Evaluation Error section to understand how to resolve those issues.
Common Variable Equation Expressions
AND - Using the AND expression allows you to compare multiple conditions to evaluate for a True (1) or False (0) result if all the conditions are met
Example: XDIM=15
Variable Name: XDIM_LARGE Formula: =XDIM>10 Result: 1
Variable Name: XDIM_SMALL Formula: =XDIM<=20 Result: 1
Variable Name: XDIM_TRUE Formula: =XDIM_LARGE AND XDIM_SMALL Result: 1
Example: XDIM=5
Variable Name: XDIM_LARGE Formula: =XDIM>10 Result: 0
Variable Name: XDIM_SMALL Formula: =XDIM<=20 Result: 1
Variable Name: XDIM_TRUE Formula: =XDIM_LARGE AND XDIM_SMALL Result: 0
OR - Using the OR expression allows you to compare multiple conditions to evaluate for a True (1) or False (0) result if at least one condition is met
Example: XDIM=15
Variable Name: XDIM_LARGE Formula: =XDIM>10 Result: 1
Variable Name: XDIM_SMALL Formula: =XDIM<=20 Result: 1
Variable Name: XDIM_TRUE Formula: =XDIM_LARGE OR XDIM_SMALL Result: 1
Example: XDIM=5
Variable Name: XDIM_LARGE Formula: =XDIM>10 Result: 0
Variable Name: XDIM_SMALL Formula: =XDIM<=20 Result: 1
Variable Name: XDIM_TRUE Formula: =XDIM_LARGE OR XDIM_SMALL Result: 1
TRUNC - Using the TRUNC expression allows you to truncate (shorten) the resulting value to the integer with no decimal points.
Example: 10/3
Variable Name: Equation Formula: 10/4 Result: 2.5
Variable Name: TRUNC_EXAMPLE Formula: =(TRUNC(10/4)) Result: 2
ROUND - Using the ROUND expression allows you to round the resulting value to the nearest integer with no decimal points.
Example: 10/3
Variable Name: Equation Formula: 10/4 Result: 2.5
Variable Name: ROUND_EXAMPLE Formula: =(ROUND(10/4)) Result: 3