SDL Wizards are easy to create. Lets walk step by step through the process of creating a simple SDL wizard.
1. Create a variable driven SDL program.
Remember the four sided square. We can change that into a wizard where you can specify the length of the side and the number of sides.
r{d1,90}4
the variable components here are:
1 = length of side
90 = heading change
4 = occurrences
The 90 heading change is really 360 degrees divided by the occurrences and so can be calculated. The other 2 are input variables so lets define them. The syntax for variable definition is in the SDL reference under assignment.
<len=1>
<side=4>
The variable names len and side can be anything you like as long as they start with an alpha character. Now we can use those variables in SDL as follows:
r{d(len),(360/side)}(side)
You can see the variables have been inserted into the SDL command by way of functions. By changing the values of len and side you can create any size equilateral polygon. The completed variable driven SDL program is the foundation of a SDL Wizard.
<len=1>
<side=4>
r{d(len),(360/side)}(side)
2. Create the SDL Wizard from the program
This step is planned to be automated in a future version of D2nc. For now, this has to be done manually. The wizards are kept in the sub-directory C:\D2nc\Wizards
Wizards are XML files with a .d2w extension. The format for the XML file is provided in a template in this directory called C:\D2nc\Wizards\Sample.d2w.txt
Copy this template to another file, giving it the name of the template as you would like it to appear in the wizard selection screen. In this example copy it to a file "My polygon wizard.d2w". The wizard selection screen will only show files with the extension .d2w
Edit this file you created in notepad or some other text editor.
The contents of the new file you copied from the template should be:
<title> and <desc>
This text is shown at the top of the wizard parameter entry screen as a way to explain how the wizard works.
<graphic>
The name of a .jpg file used to illustrate the wizard. If no name is entered or the name entered is not found, a default "no image found" will be displayed. The image can be created with any screen capture and paint application that saves jpg files. The image will scale to fit in the graphic window but the actual size is 340x340 pixels. It is always better to create graphics exactly this size as scaling causes loss of quality.
<parameters><param>.....</param><param>.....</param>...</parameters>
This <param> section contains the four fields <prompt>, <variable>, <value> and <mvalue>. The <param> section can be repeated up to a maximum of 12 times within the <parameters> section.
<prompt>
Text describing the input parameter.
<variable>
The name of the variable used in the static part of the SDL program.
Note! A variable named tool_dia has special meaning when used in a wizard. The value entered for tool_dia is passed as a hint to the centerline tool path definition and pre-fills the tool 0 dia with this value.
<value> and <mvalue>
The default value entered in the parameter entry screen. The <mvalue> is the default value if D2nc is in metric mode.
<SDL> <shape>
The <SDL> section contains <shape> parameter which contains the static part of the SDL program. The SDL program must be placed within the XML <![CDATA[ and ]]> so that it is not interpreted as XML code.
<?xml version="1.0" encoding="ISO-8859-1"?>
<wizard>
<title>My Polygon Wizard</title>
<desc>Enter the length of a side and the number of sides to generate an equilateral polygon.</desc>
<graphic>polygon.jpg</graphic>
<parameters>
<param>
<prompt>Enter the length of a side</prompt>
<variable>len</variable>
<value>1</value>
<mvalue>25</mvalue>
</param>
<param>
<prompt>Enter the number of sides</prompt>
<variable>side</variable>
<value>4</value>
<mvalue>4</mvalue>
</param>
</parameters>
<SDL>
<shape>
<![CDATA[
r{d(len),(360/side)}(side)
]]>
</shape>
</SDL>
</wizard>
3. Test your new wizard!
Load D2nc and click on the wizard icon. You will find your newly created wizard shown in the list of available wizards.
Click on the "My polygon wizard" button to show the Wizard Parameter Entry screen.
Change the length to 0.5 and the number of sides to 6 and then click the OK button.
In the shape description area you will see the generated SDL. In the shape display area, the resultant shape.
Congratulations on creating your first SDL Wizard!