You create macros using C#. Macros are delivered to the system .\master\macro folder. Save macros you create to the .\master\macro folder. You must code macros and debug mathematics in the macro code outside of the Smart Production Cutting application.
The software compiles all of the macros when you start the Cutting application. This automatic compilation procedure compares the contents of the .\master\macro with the contents in the \macro\bin folder. The software recompiles a macro if the ncs-macro file is newer than the compiled .dll file.
The graphic below shows the structure of a macro file.
Header - parameter definitions
Define macro header parameters as public. The Smart Production Cutting application uses these variables in the user interface. If you do not use the public definition, the variable is global at the macro level; however, such variables are not displayed in the interface.
Example
public double H = 1000.00;
GetInfo
Returns the macro name to the user interface. Use GetInfo() to define the name of the macro. This will return the macros name to the user interface.
Example
public override String GetInfo()
{
return "Rectangle A";
}
GetParameterInfo
Displays a description for the user-defined variable. You need to edit the GetParameterInfo(String) function for each variable.
Example
public override String GetParameterInfo(String name)
{
switch (name)
{
case "H":
return "Height of the rectangle";
}
return "";
}
Execute
Contains the macro code. You must include the macro code in the Execute() function and its sub-functions.
Example
public override void Execute()
{
…..
}
Additional commands
Include the commands below to create actual geometry.
To draw a line: AddLine(start_x, start_y, end_x, end_y)
To draw an arc: AddArc(center_x, center_y, start_x, start_y, end_x, end_y)
To draw a circle: AddCircle(center_x, center_y, radius)
-
You define local variables in regular C# code as shown below:
double x,y
-
You can use mathematic functions such as sin() and cos() from System.Math class library in the Microsoft .NET framework. Define such functions in the macro code as shown below:
Math.<function>
-
Function descriptions and sample code are available from the Microsoft MSDN web site.
-
The software displays minimal messages when it encounters errors during compilation.
Copy a macro file that is similar to what you need, and then make the necessary modifications and additions to the copied macro.