Index


RISC World

RiscCAD Reference Manual

RISCWorld

Appendix 1 - Output drivers

What is an output driver

The RiscCAD application includes a programmable output driver. An output driver can be used for driving a plotter or for producing other forms of output, such as DXF files, CSV files or Parts list information.

The primary purpose of the output driver is to provide support for plotters and drivers for common plotters are supplied.

An output driver allows RiscCAD to send data either to an output channel, usually the parallel or serial port, or to a file, in virtually any format required. Most CAD programs work on fixed format output. This means that the output generated is fixed by the program and the user has very little control over it. In some cases this is satisfactory as users may not want to change the output of a program, but there are so many different devices that data can be sent to and so many ways in which drawing data can be used that a programmable output driver is almost essential.

Loading an output driver

Output drivers are stored in the !Drivers application. Double click on the application icon to display the available drivers.

To load a driver when RiscCAD is running drag the script file onto the Plot dialogue box. The driver will be loaded and used for future output.

The driver name is shown in the title bar of the plot dialogue box.

Driver files must have the filetype set to TEXT (&FFF).

Creating a default driver

When RiscCAD is loaded it checks for the existence of a file called Driver in the !RiscCAD.Default directory. If this file exists it will attempt to load it as the plotter driver. If the file contains errors, or is not a driver script file, an error message will be displayed and plot output will be disabled until a valid driver is loaded.

RiscCAD is supplied with a HPGL driver in the Default directory. This may be deleted and replaced with another driver if required.

Script file overview

The output driver is driven from a script file. In its simplest form this can be considered a text file, although the contents look odd. When a script file is loaded the entries are scanned and decoded. The order of entries is important as this is the order in which the entries will be processed.

A script file consists of commands, keywords and output sequences. In the output sequence reference may be made to the current object such as its XY coordinate, size, layer etc. It is also possible to use conditional operators so a sequence will only be processed if a certain condition is met. This is used extensively in the DXF driver to decode the required text output.

An example script file is shown. This provides basic object listing capabilities. It should give a basic idea how a script file works.

    name        "Object Lister"
    type        "FFF"
    terminator    "13"                 
    decimal        "1"
    auto        "1"
    start        "Object listing"
    finish        "End of list"
    move        "Move from (x1) to (y1)"  
    line        "Line from (x1),(y1) to (x2),(y2)"
    circle        "Circle at (x1),(y1) - radius(rad)"
    circle_fill    "Filled circle at (x1),(y1) - radius(rad)"
    arc        "Arc at (x1),(y1)"
    text        "Text (text),size (size) at (x1),(y1)"
 

Script commands

Script file commands set general output characteristics, they do not themselves cause any output. Commands can appear in any order in the file. If a command appears more than once, the last entry becomes the valid setting, with the exception of the end command, which terminates the file.

If a command is omitted the default value is used. All commands must be lower case.

Command values should be contained within double quotes ("") with at least one space between the end character of the command and the start of the double quotes. See the example drivers at the end of this manual for example syntax.

  auto

The auto command ends the terminator character at the end of each sequence. Some plotters do not require terminators after each command. In this case turn auto off and insert a terminator only where required using the (t) operator. The DXF driver makes extensive use of this function.

   Example

    auto    "0"
    auto    "1"
 
The default is "0".

  byte

Using the byte command allows you to redefine the byte header character. This character should not appear anywhere else in a driver listing. Do not use any of the characters used for val_start/val_end/stat_start or stat_end.

   Example

    byte    "?"
 
The default value is "|".

  decimal

This sets the output accuracy. The permitted range is 0 to 3 decimal places. For plotters this parameter can usually be set to 0. Care must be taken if text sizes are to be output as 1.5 would be output as 1 (this can be overcome by using the dp0, dp1,dp2 or dp3 commands) so if you have turned off Explode beware how you output text size.

   Example

    decimal "0"
    decimal "3"
 
The default is "3".

  end

End signals the end of the driver file. This is optional as RiscCAD will terminate the script input at the end of the file anyway, but using this command allows you to put helpful comments after the end command.

  explode

Explode sends text to the plotter as component lines instead of using the text output sequence. This function can be used for various reasons, for example, you could turn explode off and use the plotter's built in text font, which improves plotting speed.

If outputting DXF turning explode off sends out text in a form that DRAW can convert to outline fonts. However, turning explode on means that plotted output is exactly as shown on screen.

   Example

    explode "1"
    explode "0"
 
The default is "0".

  stat_start/stat_end

These allow the user to re-define the statement markers. By default RiscCAD uses the [ and ] characters. If these are required in an output sequence they may be re-defined. Be sure not to include these elsewhere or the output will not be decoded correctly.

Do not use the same values as those assigned to var_start/var_end or byte.

   Example

    stat_start  "stat_end  "}"
 
The default values are "[" and "]".

  terminator

Sets the character used as the terminator. Terminator characters tell a plotter where a command ends and differ between plotters. If the auto command has been set to On this character will be sent at the end of each output sequence.

Note that the ASCII value is entered, not the character itself. This makes it easier to use control codes as terminators. Only one character can be used as the terminator.

   Example

    terminator    "13"
    terminator    "3"
 
The default is "13" (carriage return)

The terminator is inserted into the command sequence using (t).

  type

This lets you tell RiscCAD how to set the filetype of the output file if you are plotting to a file. The filetype must be valid or an error will be given and the file will not be plotted. This command has no effect if you are not plotting to a file.

   Example

    type    "FFD"
    type    "DEA"
 
The following drivers set the listed filetypes.

   DXF    &DEA

   CSV    &DFE

   Object lister    &FFF

All other drivers set the type to &FFD (Data).

  unit

Sets the number of units required per mm. Most plotters do not work on a 1 to 1 basis so 1mm is not equal to one plotter unit. HPGL plotters require a value of 40, ie each plotter unit is 0.025mm. GRAPHTEC plotters require a unit of 10, each plotter unit being 0.1mm. For non-plotter output, ie DXF, CSV etc, this should be 1.

   Example

    unit    "40"
    unit    "1"
 
The default is "1".

  var_start/var_end

As mentioned previously users can include maths operators inside an output sequence. For complex maths structures it is usual to use brackets (). RiscCAD however, uses these brackets as a signal to insert a value, and so they cannot be used for calculations.

The var_start and var_end commands lets the user re-define the characters used for the value markers. Be careful to use characters you do not need to use anywhere in the output sequences or the output will not be decoded correctly.

Do not use the same values as those assigned to stat_start/stat_end or byte.

   Example

    var_start    "var_end        "}"
 
The default vales are "(" and ")".

Keywords and variables

Keywords appear at the start of each output sequence. They tell RiscCAD which object or function the following sequence relates to. Some keywords can be used more than once, thus allowing more than one line of output for each object. The sequences pointed to by the keywords are processed in the order they appear in the file.

Keywords must be in lower case. Any keyword can appear any number of times, with a few exceptions. The command sequences are processed in the order they appear in the file and all keywords for the same object type must follow each other. For example, the following would result in incorrect output.

    line        "PU PA(x1),(y1);PD PA(x2),(y2);"
    point        "PU PA(x1-unit*scale),(y1-unit*scale);"
    point        "PD PA(x1+unit*scale),(y1+unit*scale);"
    line        "PU PA(x1),(y1);PD PA(x2),(y2);"
 

Object parameters

As can be seen from the above script the object parameters are contained in brackets () and each has a specific name. Several parameters can be used with all objects, but some only contain valid values for certain object types.

Object specific parameters are described with their keywords in the following section.

If single control codes are required they can be inserted using the | operator. The two digit code after this character is output, eg

|27 
sends an escape character (27). Note that even with control codes less than 10 two digits must be used. eg
|03
.

Global parameters

The global parameters which can be used in a script file are described below. All parameters must be enclosed in brackets () and must be in lower case. The usual maths operators can be used on parameters, eg (x1*40) or (COSangle1).

When performing maths calculations be careful not to include other sets of brackets () (unless you have re-defined var_start and var_end) or the output will be incorrect.

    layer        Current layer (1-16)
    pen        Current pen number (1-8)
    speed        Current pen speed (1-10)
    thickness    Pen thickness taken from setting file
    t        Terminator character
    paperx        Paper X dimension (mm)
    papery        Paper Y dimension (mm)
    unit        Number of plotter units per mm
    scale        Scale of plot output
    dp0        Use no decimal places for next parameter
    dp1        Use one decimal place for next parameter
    dp2        Use two decimal places for next parameter
    dp3        Use three decimal places for next parameter
 

Conditional operators

As described earlier conditional operators can be used to tailor the output. The DXF driver uses this to set up the required text sequences. Conditional operators must be contained within [ ] brackets (these can be re-defined with the stat_start and stat_end commands). These statements return either TRUE or FALSE. If the condition is TRUE execution of the line continues, if FALSE execution ceases for that line.

   Example

  text  "0(t)TEXT(t)8(t)(layer)(t)10(t)(x1)(t)20(t)(y1)(t)40"
  text  "[italic=0][underline=0]1(t)(text)(t)50(t)(angle1)"
  text  "[italic=0][underline=1]1(t)%%U(text)(t)50(t)"
 
In the above sequence the first line will always be processed. The second line will only be processed if italic text is off and underline text is off. The third line will only be processed if italic text is off but underline text is on.

Keywords dp0-dp3 force the next parameter to the specified number of decimal places

   Example

    decimal        "3"
    dp0(layer)(t)20(t)(x1)(t)
 
would produce:

    8
    20
    32.564
 
- assuming the objects layer was 8.

Keywords in detail

  arc

The output sequence following the arc keyword will be output every time an arc is plotted. It must follow on the same line enclosed by double quotes and with a space between.

   Example

  arc  "PU PA(x2),(y2);PD AA(x1),(y1),(angle2-angle1),5;"
 
Available parameters:

    x1    centre x of arc
    y1    centre y of arc
    x2    start x of arc (CCW)
    y2    start y of arc (CCW)
    x3    end x of arc (CCW)
    y3    end y if arc (CCW)
    angle1    angle from centre to start of arc in degrees
    angle2    angle from centre to end of arc in degrees
    rad    radius of arc
 
If no arc sequence is present arcs will not be output.

  circle

The output sequence following the circle keyword is output every time a circle is plotted. The sequence must follow on the same line, enclosed by double quotes and with a space between.

   Example

    circle        "CI(rad),3600,5"
    circle        "CA(x1),(y1),(rad)"
 
   Available parameters:

    x1        centre x of circle
    y1        centre y of circle
    rad        radius of circle
 
If no circle sequence is present circles will not be output.

  circle_fill

The output sequence following the circle_fill keyword will be output every time a filled circle is plotted. The sequence must follow on the same line, enclosed by double quotes and with a space between.

The resident electrical symbols employ filled circles. The joining dot is an example. To plot these correctly you should program a filled circle code. Most plotters support this but if you are using a plotter that does not you can build up a filled circle using concentric smaller circles. You will not need many circle sequences for this as most symbols are used at a small size.

   Example

    circle_fill      "PU PA(x1),(y1);WG(rad),0,3600,4;"
    circle_fill      "PU PA(x1),(y1);CI(rad),5;"
 
   Available parameters:

    x1        centre x of circle
    y1        centre y of circle
    rad        radius of circle
 
If no circle_fill sequence is present filled circles will not be output.

  finish

The finish sequence is sent at the end of the plot. It is sent only once and should contain all the commands required to terminate the plot. For a plotter this would normally require returning the pen to the station, and possibly outputting a pause command to prevent further plotting. The HPGL drivers do this.

The DXF output script uses this to output the trailer sections.

   Example

    finish           "PU PA,0,0;NR;"
 
   No available parameters.

  line

The output sequence following the line keyword will be output every time a line is plotted. The sequence must follow on the same line, enclosed by double quotes and with a space between.

The line sequence should include all the code necessary to move the raised pen to the start of the line, then lower the pen and move to the end of the line. It may also be necessary to raise the pen at the end of the line. Some plotters can perform this function in one command (Graphtec) but others such as HPGL cannot.

   Example

    line    "PU PA(x1),(y1);PD PA(x2),(y2);"
    line    "Line from (x1),(y1) to (x2),(y2)(t)"
 
   Available parameters:

    x1    start x of line
    y1    start y of line
    x2    end x of line
    y2    end y of line
 
If no line sequence is present lines will not be output. This also means that if explode is on, text may not be output correctly. This would depend on the text_line keyword being set.

  name

The name keyword allows you to assign a name to the driver. This name will appear in the plot window and in the message window when plotting. The length should be no longer than 30 characters.

   Example

    name    "Draft Pro DXL (7575A)"
 
   No available parameters.

  pen

The pen keyword allows you to set the command to change the pen. The pen select sequence is sent at the start of each layer being plotted.

   Example

    pen    "SP(pen);"
 
   Available parameters:

pen       required pen number (1-8)

If this sequence is omitted no pen select requests will be sent to the plotter. This will usually mean the plotter will use its default pen.

  point

The output sequence following the point keyword will be output every time a point is plotted. The sequence must follow on the same line, enclosed by double quotes and with a space between.

Most of the time points will not require plotting, as they are usually only used for construction. If this is the case the point keyword can be omitted. If points are required it is up to the user to decide how to plot the point. The example given below draws a small cross, 1mm around the centre of the point. Notice the use of the values unit and scale to ensure the correct number of plotter units are sent and that the correct output is given if the plot has been scaled.

   Example

    point    "PU PA(x1-unit*scale),(y1-unit*scale);"
    point    "PD PA(x1+unit*scale),(y1+unit*scale);"
    point    "PU PA(x1-unit*scale),(y1+unit*scale);"
    point    "PD PA(x1+unit*scale),(y1-unit*scale);"
 
   Available parameters:

    x1    point x 
    y1    point y
 
If no point sequence is present points will not be output.

  rectangle

The output sequence following the rectangle keyword will be output every time a rectangle is plotted. The sequence must follow on the same line, enclosed by double quotes and with a space between.

Some of the built-in symbols use rectangles to form their output. If you do not use symbols you can omit this sequence.

   Example

    rectangle    "PU PA(x1),(y1);FT2(t)RA(x2),(y2);"
 
   Available parameters:

    x1    low x of rectangle
    y1    low y of rectangle
    x2    positive offset to opposite corner - x value
    y2    positive offset to opposite corner - y value
 
If no rectangle sequence is present rectangles will not be output.

  speed

The speed keyword allows you to set the command to change the pen speed. The pen speed depends on which media and type of pen you are using. Consult your plotter manual for recommended speeds and media.

The speed sequence is sent at the start of each layer being plotted.

   Example

    speed    "VS (speed*10);"
 
   Available parameters:

speed    speed of current layer

If this sequence is omitted no pen speed command will be sent to the plotter. This will usually mean the plotter will use a default speed.

  start

This output sequence is sent at the start of the plot. It is only sent once and should contain all the commands required to initialise the output device. For a plotter this would normally require resetting the parameters used on the last plot.

The DXF output script uses this to output the header sections and style tables. If you look at the DXF driver you will see there are a lot of start sequences.

   Example

    start    "IN;DT(t);"
 
   No available parameters.

  style1-6

The style1 to style6 keywords are output depending on the line style of the layer being plotted. They are output once for each layer as it is plotted. This allows users to set the plotter line style to match the line style selected on the drawing. If only solid lines are used these keywords can be omitted.

Only one line of output is permitted per style.

   Example

    style1    "LT;"
    style2    "LT2,0.5"
    style3    "LT4,2.0;"
    style4    "LT6,2.0"
    style5    "LT5,2.5"
    style6    "LT;" 
 
   No available parameters.

  text

The output sequence following the text keyword will be output every time text is plotted. The sequence must follow on the same line, enclosed by double quotes and with a space between.

The text output sequence will only be considered for output if the explode option is off. Otherwise, text will be output as its component lines. Using the text keyword you can program a plotter to use its internal font, thus greatly improving plot speed.

For non-plotter directed output the explode command should be off and you should use this keyword to output all text. See the DXF script for examples of this.

   Example

    text    "SI (size/20),(size/10)(t)"
    text    "[italic=0]SL0;"
    text    "[italic=1]SL-0.4;"
    text    "DI (COSRADangle1),(SINRADangle1);"
    text    "PU PA(x1),(y1);LB(text)(t)"
 
   Available parameters:

    x1        unjustified start x of text

    y1        unjustified end x of text
    x2        justified start x of text
    y2        justified end x of text
    text        text string
    size        text size in 10ths of mm
    angle1        text angle in degrees
    italic        TRUE if italic is on
    underline    TRUE if underline is on
    box        TRUE if text is boxed
    format        1=left, 2=centre, 3=right justified text
    box_x1        box corner 1
    box_y1        box corner 1
    box_x2        corner 2
    box_y2        corner 2
    box_x3        corner 3
    box_y4        corner 3
    box_x4        corner 4
    box_y4        corner 4
    linex        start x of underline
    liney        start y of underline
    linex1        end x of underline
    liney1        end y of underline
 
The box, italic and underline parameters are provided to allow the user to change the commands processed depending on the format of the text.

The unjustified xy coordinates are where the xy coordinates of the text are stored. For centre justified text this would be the middle of the text string. As most plotters do not support any type of text justification these coordinates are no use when plotting. For this reason the justified xy coordinates are available. These coordinates are the point at the lower left corner of the first letter, regardless of justification.

  text_line/move

For plotters to draw a line you should include a sequence to move the raised pen to the start of the line and a sequence to lower the pen and move to the end of the line. This would be included in the line output sequence. Some plotters can do this automatically in one command but others, such as HPGL, do not.

When the explode option is on plotting text can make the plotter pen "chatter" as it repeatedly raises and lowers the pen even though consecutive lines start and end on the same point. To overcome this two extra keywords are implemented, move and text_line. The move sequence is the code required to move the raised pen to the required point, leaving it raised. The text_line sequence is the code required to lower the pen and move to the required location. When explode is on RiscCAD will only output a move sequence if the next line does not start at the current pen position, otherwise the text_line sequence will be used instead.

   Example

    move        "PU PA(x1),(y1);"
    text_line    "PD PA(x1),(y1);"
 
move should be present if you are exploding text or it may be incorrectly output. If the text_line sequence is omitted RiscCAD will use the line sequence instead if it exists.

NOTE: Internal symbols are plotted in the same way as text, regardless of the explode command. It is therefore good practice to include the text_line keyword where symbols are used.

   Available parameters:

    x1    end x of line
    y1    end y of line
 

Programming examples

This section lists some of the supplied drivers. Careful study of these drivers should give users a good idea of how the output driver system works.

  The HPGL drivers

The following driver gives exploded text in HPGL format. Although the name is tailored to a specific plotter, it should work on any HPGL device.

    name        "Draft Pro DXL (7575A)"
    type        "FF4"
    pen        "SP(pen);"
    speed        "VS (speed*10);"
    decimal        "0"
    terminator     "13"             
    unit            "40"  
    explode          "1" 
    auto         "0"
    start        "IN;DT(t);"
    finish        "PU PA,0,0;NR;"
    move        "PU PA(x1),(y1);"  
    line        "PU PA(x1),(y1);PD PA(x2),(y2);"
    point        "PU PA(x1-unit*scale),(y1-unit*scale);"
    point        "PD PA(x1+unit*scale),(y1+unit*scale);"
    point        "PU PA(x1-unit*scale),(y1+unit*scale);"
    point        "PD PA(x1+unit*scale),(y1-unit*scale);"
    text_line    "PD PA(x2),(y2);"
    circle        "PU PA(x1),(y1);CI(rad),5;"
    circle_fill    "PU PA(x1),(y1);WG(rad),0,3600,4;"
    circle_fill    "PU PA(x1),(y1);CI(rad),5;"
    arc  "PU PA(x2),(y2);PD AA(x1),(y1),(angle2-angle1),5;"
    rectangle    "PU PA(x1),(y1);FT2(t)RA(x2),(y2);"
    style1        "LT;"
    style2        "LT2,0.5"
    style3        "LT4,2.0;"
    style4        "LT6,2.0"
    style5        "LT5,2.5"
    style6        "LT;"
    end
 
The following driver gives standard text in HPGL format. Although the name is tailored to a specific plotter, it should work on any HPGL device.

    name        "Draft Pro DXL (text)"
    type        "FFD"
    pen        "SP(pen);"
    speed        "VS (speed*10);"
    decimal        "3"
    terminator    "13"             
    unit        "40"  
    explode        "0" 
    auto        "0"
    start        "IN;DT(t);"
    finish        "PU PA,0,0;NR;"
    move        "PU PA(x1),(y1);"  
    line        "PU PA(x1),(y1);PD PA(x2),(y2);"
    text_line    "PD PA(x2),(y2);"
    circle        "PU PA(x1),(y1);CI(rad),5;"
    circle_fill    "PU PA(x1),(y1);WG(rad),0,3600,4;"
    circle_fill    "PU PA(x1),(y1);CI(rad),5;"
    arc        "PU PA(x2),(y2);PD AA(x1),(y1),(angle2-
            angle1),5;
    rectangle    "PU PA(x1),(y1);FT2(t)RA(x2),(y2);"
    text        "SI (size/20),(size/10)(t)"
    text        "[italic=0]SL0;"
    text        "[italic=1]SL-0.4;"
    text        "DI (COSRADangle1),(SINRADangle1);"
    text        "PU PA(x1),(y1);LB(text)(t)"
    text        "[underline=1]PUPA(linex),(liney);PD PA
            (linex1), (liney1);"
    text        "[box=1]PU PA(boxlx),(boxly);"
    text        "[box=1]PDPA(boxlx),(boxhy),(boxhx),
            (boxhy),(boxhx),(boxly),(boxlx),(boxly);"
    style1        "LT;"
    style2        "LT2,0.5"
    style3        "LT4,2.0;"
    style4        "LT6,2.0"
    style5        "LT5,2.5"
    style6        "LT;"
    end
 
  The GRAPHTEC driver

The following driver gives exploded text in GRAPHTEC format.

    name        "Graphtec MP3x00 range"
    type        "FFD"
    pen        "J(pen),"
    speed        "!(speed*10)(t)"
    decimal        "0"
    terminator    "13"             
    unit        "10"
    explode        "1"
    auto        "0"
    start        ":H(t)B40,"
    finish        "H(t)M0,0(t)"
    move        "M(x1),(y1)"  
    text_line    "D(x1),(y1)(t)"
    line        "M(x1),(y1)D(x2),(y2)(t)"    
    circle   "M(x1),(y1)W(x1),(y1),(rad),(rad),0,3600,0(t)"
    circle_fill    "M(x1),(y1)%13,0,(rad),0,3600,3,0,0(t)"
    arc     "W(x1),(y1),(rad),(rad),(angle1),(angle2),0(t)"
    rectangle    "M(x1),(y1)D(x1),(y2),(x2),(y2),(x2),(y1),
            (x1),(y1)(t)"
    style1        "L0,"
    style2        "L3,"
    style3        "L6,"
    style4        "L8,"
    style5        "L0,"
    style6        "L0,"
    end
 

RISCWorld

 Index