Macro Command Reference

  1. Comments can only be inserted in the .mac file outside of MACRO/ENDM boundaries. See fcw32.mac for examples.

  2. A macro is defined by the sequence:

MACRO name

....

.....macro commands

....

ENDM

Note that neither MACRO or ENDM is valid from the command line.

  1. Variable names start with letters, (_) or ($) followed by digits, letters, (_)s or ($)s. Variable names are limited to 32 characters.

  2. In macros, scripts, or menu items, the sequence: 

  3.   ^Dprompt

displays the prompt text (ended with CR only!) and waits for live input.

^D forces live input for an entire getdata, which may be more than one point. For example, use BOX ^D not BOX ^D ^D.

^D keeps the appropriate cursor and allows an entire pick cycle (MOVE ^D 0,0 1,1).

^D can be interrupted by a modifier or zoom from the menu or a toolbar, but only if the menu file has a ^D for each command line input. Look at the modifiers and icons in fcw32.mnu.

Any ^D that doesn't have a prompt spelled out "inherits" the prompt from the last ^D that had one, even if it's in a completely different macro!

  1. The variable setting commands are:

  2. FUNCTION

     

    SYNTAX

    Append Word. This concatenates variables

     

    APND variable text.word.string

    Get Point

     

    GP variable point.expression

    Get Entity

     

    GE variable point.expression

     

    GETEXTL variable

    Get Extents high right point

     

    GETEXTH variable

    Get Extents width

     

    GETEXTX variable

    Get Extents height

     

    GETEXTY variable

    Get Current Symbol Scale

     

    GETSYMSCALE variable

    Get Reference (frozen) Entity

     

    GR variable point.expression

    Get Value

     

    GV variable real.expression

    Get Number

     

    GN variable integer.expression

    Get Word

     

    GW variable text.word.string

    Get Line

     

    GL variable text.string (not delimited by space or tab)

    Get Open File Name

     

    GFNO variable filename.extension

    Get Open File Name w/pattern

     

    GFNOP variable filename.extension (can use * or ?)

    Get Save File Name

     

    GFNS variable filename.extension

    Get Save File Name w/pattern

     

    GFNSP variable filename.extension (can use * or ?)

    Gets the relative relative path

     

    GRFN variable filepathname

    Store distance between points

     

    GDIST variable point.expression point.expression

    Store angle point to point

     

    GBRNG variable point.expression point.expression

    Store X coordinate of point

     

    GETX variable point.expression

    Store Y coordinate of point

     

    GETY variable point.expression

    Save variable values in a file

     

    SAVEVARS

     

    Transcendental functions ( for example, GSIN MySin 30 stores 0.5 in MySin ):

    FUNCTION

    SYNTAX

    Store result of Sin(X) in variable

    GSIN variable argument

    Store result of Cos(X) in variable

    GCOS variable argument

    Store result of Tan(X) in variable

    GTAN variable argument

    Store result of Arc Sin(X) in variable

    GASIN variable argument

    Store result of Arc Cos(X) in variable

    GACOS variable argument

    Store result of Arc Tan(X) in variable

    GATAN variable argument

     

    Values stored by these functions are formatted as numeric with 9 decimal places. The expressions are delimited by : a space, a semicolon, the equal sign, the ENTER key, or the TAB key. They can contain variable names defined above, the math operators (+ - * / ( ) ), and units operators ( ' , " ,cm ,mm ,m ,km). Note: The expression analyzer does not support unary minus. This means that if A=2, -A doesn't work. But 0-A works fine (-2).

    1. Nothing is case sensitive. The order of operations are:

    parenthesis (highest priority)

    multiply or divide

    add or subtract

    units conversion operators

    add or subtract after a units postfix operator (lowest priority)

    1. Labels are a colon followed by a letter and then optionally more letters or digits or the _ character. Labels cannot contain spaces or tabs. Do not use the starting colon on a label reference (GO/IF) but use it where the label occurs:

    :MyLabel

    .....

    ..... other macro commands

    .....

    GOTO MyLabel

    1. The control transfer commands are:

    2.  

      GO label 

       

      GOTO label 

       

      IFP real.expression label (if expression >0 then go to label)

       

      IFZ real.expression label (if expression =0 then go to label)

       

      IFN real.expression label (if expression <0 then go to label)

       

      IFERR label (if error then go to label)

      image\SHORTCUT.gif

       

      IFDEF variable label (if variable is defined, go to label)

      image\SHORTCUT.gif

       

      ASKBOX title line…line blank.line ("No" response = IFERR flag on)

      1. Use the PAUSE command to suspend macro execution for a designated number of seconds. Code syntax:

      PAUSE n.nnn

      where n.nnn represents a real number of seconds.

      Any keypress or left mouse button click will terminate the current pause early, without that key or click being treated as input data. PAUSE can be used to load and display several files in sequence. PAUSE will force a redraw after each file and ask for a keypress to continue.

      1. Use the WAIT command to pause a script or macro until a user closes a message box..

      2. Use ECON and ECOFF to suppress echo of text on the prompt line. If a macro goes wrong while echo is off, it's almost impossible to tell what is happening. Don't add the ECOFF command to your macro until the macro is completely tested and debugged.

      3. Use the RUNAPP command to start another Windows application. RUNAPP can accept command line arguments.

      4. If a .mac file has the same name as an .fcw drawing file located in the same folder, the .mac file will automatically load when the .fcw file is loaded. This feature is helpful when creating macros that only work with specific drawings.

      5. The GE command (get entity) works like the GP command (get point), except that it displays a pick box cursor when expecting input. After an entity is selected, the nearest point (x,y coordinates) on the entity is stored in the variable. GE uses an implied ON modifier to ensure that the point is actually on an entity. IFERR is returned if no valid entity is picked. Use the GR command to select entities on frozen layers.

      6. The macro command SAVEDXF saves the current drawing as a DXF file "CurDwgName.DXF" with no input required. Note that the SAVEASM command can also save DXF or DWG files - but you must specify a file name as well as type: SAVEASM MyFile.DXF or SAVEASM MyFile.DWG.

      7. The APND command concatenates strings. If AA = "alpha", then APND AA beta changes AA to be "alphabeta". The APND command can be used to concatenate to string variables (i.e., APND vara varb). If the second variable, varb, consists of a null value, or is not specified, then a semicolon is appended to vara.

      8. Use the OPENDOC <filename.type> command to open the application associated with the file. As an example, OPENDOC WORK.TXT opens Notepad with the file work.txt. If your system has a different application associated for .txt files, then it will open with work.txt instead.

      9. The KEEPTHA command copies the final height and angle of the last text entered to the current text specs, even if these settings were determined using dynamic cursors.

      Commands to bypass dialog boxes

      Although you can drive the Select Entity dialog boxes from a macro (MOVE A D 0,0 1,1) and the dialog boxes will not display, there are some commands intended for use in macros and scripts when you want to bypass other dialog boxes. Note: these commands do not ask user confirmation before destructive actions (like loading a different file).

      Bypass status buttons/dialogs with:

      CSNAPON, CSNAPOFF

      Cursor Snap action control

      FRAMEON, FRAMEOFF, FRAMETOG

      Frame view control

      GRIDON, GRIDOFF, GRIDT

      Grid view control

      ORTHON, ORTHOFF, ORTHT

      Orthogonal effect control

      SNAPON, SNAPOFF, SNAPT

      Snap action control

      ATCHON, ATCHOFF, ATCHT

      Attach mode control

      LOCKON, LOCKOFF, LOCKT

      Group Lock control

      XHON, XHOFF, XHTOG

      Crosshairs effect control

       

      At any prompt for a filename, precede the filename with (#) to have CC3 substitute the directory where CC3 (fcw.exe) is installed. For example, if CC3 is in c:\CC3, then,

      "menum #custom" loads the menu c:\CC3\custom.mnu,

      and

      "loadm #dwgs\sample\square" loads the drawing c:\CC3\dwgs\sample\square.fcw.

      similarly, $ is a substitute for the current directory.

      Bypass file-selection dialogs with:

      CATALOG

      Load FSC symbol catalog file by name

      CPARYM

      Insert circular part array by name

      LOADM

      Load FCW drawing file by name

      LOADMACM

      Load MAC macro file by name*

      MENUDM

      Load MNU menu by name*, becomes session default menu

      MENUM

      Load MNU menu file by name*

      OPENDOC

      Opens file in associated application

      PARTM

      Insert part by name

      PARYM

      Insert part array by name

      SAVEASM

      Save drawing file as name

      SAVEDXF

      Save drawing file as DXF file

      SAVEMACM

      Save macro file

      SCRIPTM

      Run script by name

      TEMPLATEM

      Load FCT template file by name

      TFILEM

      Insert text file by name

      WRITEM

      Create part file by name

      *Because loading a menu replaces the existing menu table in memory, CC3 ignores everything in a menu item after MENUM <filename>. Same story with "code" in a macro after LOADMACM <filename>.

      Bypass text-entry dialog with:

      TEXTM

      Insert text typed on command line

      Bypass symbol attribute dialog with:

      ATTRIBM

      ATTRIBM <tag> <prompt> <value>

      Bypass select by dialog (set selection method for subsequent List, Move, etc.) with:

       

      SELBYD

      Select by: dialog

       

      SELBYE

        each, multiple

       

      SELBY1

        each, single

       

      SELBYW

        window

       

      SELBYL

        layer

       

      SELBYC

        color

       

      SELBYP

        prior selection

       

      SELBYA

        all

      image\SHORTCUT.gif

       

      SELSAVE

      Save current SELBY mode

      image\SHORTCUT.gif

       

      SELREST

      Restore saved SELBY mode

      Preset any select method with SELBYA, SELBYE, etc. See "spiral" macro in fcw32.mac.

      To preserve the current selection method, use the SELSAVE command at the beginning of the macro, and the SELREST command at the end of the macro. Since the save stack is nested four levels deep, you can also use these commands during a macro.

      At any prompt for a layer, style or dimension style, you can:

      ·   Enter a name (including spaces) delimited by (;) or CR, or

      ·   Enter an ID number preceded by (#), or

      ·   Use the LIKE modifier, or

      ·   (If live) right-click to get the dialog box.

      Bypass layer dialogs with:

      SETLAYER

      Make a layer the current layer.

      Bypass style dialogs with:

      LSTYLE

      Set current line style

      FSTYLE

      Set current fill style

      LWIDTH

      Set current line width

      Bypass sheet dialogs with:

      SHEET

      Set named sheet current

      DELSHT

      Delete named sheet

      HIDESHT

      Hide named sheet

      SHOWSHT

      Show named sheet

      SHOWSHTF

      Shows sheets matching a text wild card

      HIDESHTF

      Hides sheets matching a text wild card

      Bypass text specs dialog with:

      TSPECF

      Set font by name (or LIKE mod)

      TSPECH

      Set text height

      TSPECA

      Set text angle

      TSPECP

      Set text spacing

      TSPECT

      Set text stretch factor

      TSPECJ

      Set text justification*

      TSPECS

      Set text style**

      *Text justification codes:

       

      Far Left

      Left

      Center

      Right

      Far Right

      Above

      16

      17

      18

      19

      20

      Top

      --

      6

      7

      8

      --

      Mid

      9

      3

      4

      5

      10

      Bottom

      --

      0

      1

      2

      --

      Below

      11

      12

      13

      14

      15

      **Text style flags (can be added, i.e. 16+32=bold italic):

      1

      Vertical

      16

      Bold

      32

      Italic

      64

      Underline

      128

      Strikeout

      Bypass Units dialog with:

      UNITM

      Set inches per drawing unit

      SETDECP

      Dec. places for dialogs, list, etc (not dimensions)

      DISTFMT

      Distance format code*

      SETFRAC

      Fraction rounding code for fractions of inches**

      *Distance format codes:

      0

      Straight numeric

      1

      Decimal inches

      2

      Fractional inches

      3

      Feet and Inches

      4

      General Metric

      5

      Millimeters

      **Fraction rounding codes - display to nearest:

      0

      Whole number

      1

      1/2

      2

      1/4

      3

      1/8

      4

      1/16

      5

      1/32

      6

      1/64

      7

      1/128

       

      Related topics

      Understanding Macros

      Load Macros

      Edit Macros

      Save Macros

      Clear Macros

      Macro Tips

      Alphabetical List of Macro Commands