WWW.DANCAD3D.COM (sm): THE OFFICIAL DANCAD3D (tm) "BETA TEST" WEB SITE.

TERMS OF USE, HOME, INDEX, SHORTCUT, WHAT'S NEW, DOWNLOADS, GET MAIN ZIP, DOCUMENTATION, VIDEO, HOOKUP#1, #2, #3, KEYWORDS

FEATURE FILM 4K+ DIGITAL CINEMA UNCOMPRESSED EDITING AND SOUND MIXING
PLUS DIY MOVIE 35mm FILM SCANNING AND DIY 35mm FILM RECORDER SOFTWARE.

DANCAD3D (tm) DRAWING EDITOR, click on image for more info. and larger images. 3D ROBOTIC ANIMATION, click on image for more info. and larger images. 3D CONTOUR SURFACE, click on image for more info. and larger images. 3D CAM TOOL PATH, click on image for more info. and larger images. STEPPER MOTORS FOR CAM, click on image for more info. and larger images. DANCAM.EXE (tm) OPERATING 3D MILL, click on image for more info. and video. IM HELP STATUS, click on image for more info. and IM address.
Kodak (tm) LAD film negative scan image made with Canon XTi (tm) DSLR. Kinema Edit list Grading Levels #1 color correction tool . Kinema Edit list Grading Curves #1 color correction tool. Kinema Edit list Grading chroma Masking tool Vector display. Kinema Edit list Grading chroma Masking tool Waveform display. Kinema Edit list Grading Sharp/Soft filter tool. Kodak (tm) LAD image color corrected positive.
Click on these thumbnails for related information about my current software, features, and IM support. Hold [Shift] and click [Reload] to refresh IM thumbnail.

If are helping "Beta Test" you should report bugs and feel free to ask questions about the program's commands, it is best to email me at tempnulbox (at) yahoo (dot) com and put "DANCAD3D (tm) 24x7 SUPPORT SUBMISSION" in the email subject line so your mail is not deleted as junk. See Section: 8 for more information about support related issues. I want you to ask questions so long as they are on the subject and relate to the current program's commands. If you do not get some kind of reply assume I did not get your message and resend it and also try voice mail, postal form, etc. All submissions and correspondence become the sole property of Daniel H. Hudgins to do with as he sees fit, so stay on subject.

SECTION: 3.4.40.0
Macro information.
This Section, Overview of Macro code information, Steps for writing Macro code, Discussion of Macro code information, Why is it called a Macro?, What is a Macro?, Example Macro files, Macro code syntax overview, Macro code syntax steps, Macro code syntax discussion, Overview of using Macros in Engineering, Steps for using Macros in Engineering, Uses of Macros in Engineering, Generating elements, Animation in Engineering Simulations, Interactive macros, and Using Macros to alter tool path files.

Copyright (C) 1986-2008 by Daniel H. Hudgins, All Rights Reserved.

No part of "This Web Site" (HTML document), including associated files, may be: distributed, sublicensed, transmitted, copied, archived, mirrored, modified, bundled, embedded, sold, given away, rented, loaned, or shared in any form without express written permission in a formal Vendor agreement contract dated and signed in ink obtained directly from Daniel H. Hudgins by registered postal mail. All agreements for permission to distribute expire after a period no greater than one year from the date of the signing of the agreement by Daniel H. Hudgins. See the current "EULA" for information regarding limited copying and storage for the purpose of "Beta Testing" "This Web Site."

To view or use the current version of this Web page you may need to reload or refresh the display of this page by your browser. Just clicking on the browser's [Reload] or [Refresh] icon may not be enough to insure that all of the page's most current contents have been cached and displayed. Some browsers may have additional commands to help display the page's most current contents such as: holding down the [Shift] key and clicking on the [Reload] icon, holding down the [Control] key and clicking on the [Refresh] icon, holding down the [Control] and [Shift] keys and clicking on the [Refresh] icon, pressing the [Control] and [F5] keys, pressing [Control] and the [R] key, or some other combination of keys or clicks. Check to see which commands your HTML browser uses to load the most current page contents into its cache and then to display them onto the screen.

This Web site is dedicated to the thousands of "users" of my programs, those who have helped test my programs over the last 22 or so years, and especially those who shared their experiences with me.

You must read this notice: This is a licensed Web site (HTML document and associated files). You must read and agree to be legally bound in contract by the Terms of Use and conditions given in the End User License Agreement ("EULA"), Legal Notices, Instructions, Warnings, Disclaimers, and all other text in "SECTION: 0" of "This Web Site" (HTML document and associated files) before reading or using any of the information, software programs, and or files, contained in, linked to, and or associated with, "This Web Site" (HTML document and associated files). Any use or "Beta Testing" of "This Web Site" constitutes your acknowledgment of your full agreement with the current End User License Agreement ("EULA") and your decision to have this current license supersede all prior and contemporaneous agreements and understandings. Information and files in "This Web Site" (HTML document and associated files) have been placed here so that long time users of "The Author's" programs DANCAD3D.COM (tm) , DANCAM.EXE (tm) , or DANPLOT.EXE (tm) could help proofread the text of the documentation files or screens displayed, and also help test data files, example files, and or any software programs that might be made available from time to time, to aid "The Author" in finding mistakes, bugs, and other errors, omissions, defects, mistakes, and faults. Everything in "This Web Site" (HTML document and associated files) is "Beta Test", "Beta Code", Experimental, Preliminary, requires proofreading, or is being evaluated for possible revision, and is NOT warranted to be free of defect. To help "The Author" report any bugs, foul-ups, defects, or mistakes that you find, see "SECTION: 8" for instructions. "This Web Site" (HTML document and associated files) and all other files and programs by Daniel H. Hudgins are made available "AS IS" without warranty of any kind express, expressed, or implied. All offers and specifications are subject to change or discontinuation without notice of any kind. Please read "SECTION: 8" of "This Web Site" (HTML document and associated files) before trying to contact "The Author."


Click here to go back to SECTION 3.0.0.0 Index for documentation pages..
Click here to go back to SECTION 3.4.0.0 Index for supplemental documentation pages..
Click here for top of DANCAD3D.COM (tm) Web site home page or here for home page INDEX.
Click here to check the current internet document if you are viewing this from a disk copy.
Note: If you want to go back to the previous link use the [Back] button in your browser.

This Section.

The text in this section was derived from the v2.5 CAE manual and some other text, and has been updated I think to about the level of v2.7. Some adjustment may be required for versions prior or subsequent to v2.7A.

You may not distribute, sell, rent, share, or give away these HTML documentation files or printed copies of them. You may not extract text from these HTML documentation files for distribution, sale, rent, sharing, or giving away. You can use the [Print] option in your browser to make one copy for yourself to mark up in order to help me proofread the text for mistakes.

Documents may be available to download from time to time, you can check SECTION: 9 to see what the current situation with regard to downloadable files is. The names of these documentation files may change, and they may be edited, combined, or eliminated in the future, without notice.

You may need to adjust your browser for best viewing of the pre- formatted text by changing the "font" size using the commands in your browser (see the help in your browser, or use the pull-down menus in your HTML browser.) If some letters in words on the screen appear to be missing or scrambled try changing the font size in your browser as this sometimes happens even though the words are spelled correctly in the HTML code.

Use the "Edit, Find in page Ctrl+F" or "Edit, Find (in this page)... Ctrl+F" command in your browser to search for keywords within the documentation text in this HTML page. You will need to search over again in the other pages in this HTML document for the same keyword since your browser may not search for a keyword beyond the current page that is loaded.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Overview of Macro code information.

This section contains a discussion of how macro instructions might be be written to be executed, i.e. read and interpreted, by DANCAD3D (tm). You might use this section as an example of some of the proper coding style you would use when you write your own macro files. See also any example macro files, *.MAC, that may be available from SECTION: 9 that you might look over to see how a macro might be written. You can use the [W]rite command in DANCAD3D (tm) to read and edit the *.MAC files.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Steps for writing Macro code.

Steps to carry out to writing Macro code files:

  1. Read all of the *.HTM files.

  2. Use the [W]rite command in DANCAD3D (tm) to look at the *.MAC files.

  3. Use the [O]utput command to make a macro by the teach method.

  4. Look at the macro you output with the [W]rite command.

  5. Try to use [W]rite to write or edit your own macro. Be sure that your macro file starts with the VERSION macro command.

  6. Use [R]un to run your macro.

  7. Repeat steps 5 and 6 until you get your macro to work.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Discussion of Macro code information.

In order for you to better understand the nuances of syntax, organization, and arrangement of the commands in the DANCAD3D (tm) macro code language you should study the example macros, *.MAC, and also any *.SUB sub-macros. Sub-macros are "helper" macros that are used by another macro.

DANCAD3D (tm) macros are made up of easily recognizable key words that correspond to the DANCAD3D (tm) menu commands, i.e. the macro command ROTATE works about the same as the menu command [R]otate. Most of the macro commands have a parameter list associated that needs to be completely stated, that is, all the parameters that go with a particular command need to follow the command keyword. Appendix B in this document should be referred to in order to figure out what parameters have been given the values seen in the example macro code.

When writing or editing DANCAD3D (tm) macros you will need to leave one or more space characters (ASCII code number #32) between each command key word and other command key words and or the parameters associated with the command key words. That is, you need to space out the words, symbols, and numbers so that the macro interpreter can tell where one thing ends and the next starts.

To read the macro source code you read from left to right and from top to bottom as in written English. The execution of commands proceeds from left to right line by line from top to the bottom until the GOTO, LOOP, or RUN commands are encountered. The GOTO command will restart the execution at a label within the macro file in order repeat or skip some of the commands given. The LOOP command is used to repeat a portion of the code several times. The RUN command will start execution of commands found in another macro file beginning at the top of that other macro file, and then when the other macro file has finished, the execution of commands in the original macro file continues with the next command after the RUN command. Passing the execution from one macro into another is called "nesting sub-routines." DANCAD3D (tm) has no limit on the size of a macro file since the macro can prompt the computer operator to insert disks with sub-routines (sub- macros) on them.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Why is it called a Macro?

From the above you know that DANCAD3D (tm) can read a file of commands that are equivalent to the DANCAD3D (tm) menu commands. A macro command means that one user defined command name (a macro filename) can represent many key words arranged in some useful sequence. In other words if you want several commands to be executed within DANCAD3D (tm). you have the choice of entering the commands from the menus or writing the commands out in a script like macro command file. When you write out a macro command file you only have to enter the filename of the macro file as your command rather than each command in turn. The macro feature is important since the complex tasks DANCAD3D (tm) is capable of can involve the execution of a sequence of hundreds of thousands of commands (loop structures would repeat a few dozen commands over and over.) You would certainly agree that simply entering the name of the macro file into the main menu [R]un command is easier than manually entering hundreds of thousands of commands from the menus!

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

What is a Macro?

A macro is a composition (list, script) of DANCAD3D (tm) commands that cause DANCAD3D (tm) to do something useful. In particular DANCAD3D (tm) macros exist as standard ASCII text files, and are made by typing in the commands with a text editor (similar to word processing) or by DANCAD3D (tm)'s automatic output macro feature. For the most part DANCAD3D (tm) macros will contain commands that carry out the tasks listed below.

Tasks most Macros carry out:

  1. Initialize the workspace and or set the video mode.

  2. Enter, Append or Load some elements into the workspace.

  3. Manipulate the elements in the workspace.

  4. Save or display the manipulated elements.

DANCAD3D (tm) is intended to be a tool that produces material things as an end product and so can operate itself from macro file, as opposed to being a program that the computer user continuously needs to interact with, such as a video game. The primary end products DANCAD3D (tm) might be used to produce are listed below.

Primary end products that might be made with DANCAD3D (tm):

  1. Printed drawings for reproduction or publication.

  2. Animated cine film, video tape, or display from harddisk.

  3. ASCII tool path files for use with DANCAM.EXE (tm) or DANPLOT.EXE (tm).

DANCAD3D (tm) was conceived to operate automatically to produce the above mentioned products. Although computers have gotten much faster than when DANCAD3D (tm) was introduced so many years ago, you still benefit from being able to tell the computer what to do in a macro file and then let the computer work while you do something else. It is very difficult to enter commands manually through the menus without making mistakes, but once you have debugged a sub-macro you can freely reuse that sub-macro over and over.

While DANCAD3D (tm) can be used manually to draw drawings in the drawing editor and the drawings can be printed manually with the commands in the [H]ardcopy sub-menu, macro files can prove useful in the automation of repetitive tasks or for DANCAD3D (tm)'s ability to print a series of drawings out automatically by scripting what files you want printed in a macro file. See the description of the macro commands DOT WORKSPACE, JET WORKSPACE, and PLOT in Appendix B of this document. The automatic output macro feature of DANCAD3D (tm) is useful in the editing of drawings and as a "fail safe" against making mistakes while drawing. An output macro file can be edited and then run to regenerate the elements in the workspace minus some error, press [O] from DANCAD3D (tm)'s main menu to turn the output macro feature on. You can also turn on or off the [O]utput macro from the drawing editor's [F]iles sub-menu.

A series of printed drawings can be photographed on an animation stand to make an animated movie. By connecting onto the audio signal across the computers loudspeaker you can automatically trigger a single frame cine movie film camera to photograph your computer's monitor. The macro commands SIGNAL and DELAY can be used to control the exposure interval for your cine film.

Those fortunate enough to have access to a single frame VCR can use the signal from the computer's loudspeaker to trigger the VCR's single frame advance. True single frame VCRs are expensive, and may not actually work very well, so it might be better to use cine film to make extended animations. Single frames can be also be saved as BMP files, other software programs might be used to convert a set of BMP files into an MPG or AVI video file that could be output to video tape, Video- CD, or possibly converted to DVD disk. If the BMP files are saved in the highest resolution SVGA mode then reduced in size for the conversion to MPG using another program that can do smoothing during size reduction, some of the jagged edges may look better than saving the BMP file at the smaller size that is actually needed for conversion to MPG.

An alternative to a single frame VCR is to use a video board that has a composite video output and record the video in real time. To get a good frame rate from the ANIMATE command in DANCAD3D (tm) you should store the numbered frame files in a RAM disk. Reading the frames off of a harddisk is usually not smooth or fast enough for good animation. A 66MHz or faster computer is also a help. You may need to adjust or disable your disk cash program to avoid changes in the frame rate when all the data in the cache is read, and the cash needs to refill.

When generating an ASCII data file tool path for DANCAM.EXE (tm) or DANPLOT.EXE (tm) with DANCAD3D (tm) you might find the macro feature useful in preparing repetitive tool cycles and other organized arrays of tool motion. Keeping the macro file for a tool path after the ASCII data file has been generated will allow you to edit the macro file and make changes with less work than trying to edit the data with the drawing editor. Since DANCAD3D (tm)'s macro language allows the operator to create menus in macros, by use of the INPUT and INPUT$ commands, you can write the macros so that the macros will ask questions about how the elements for the tool path should be made, e.g., such questions as the feed for each cut, and the tool radius. Some experience in programming might be helpful in doing such tasks since you will have to figure out how to use the various commands.

In the most basic terms DANCAD3D (tm) macros are an alternative method of operating DANCAD3D (tm). You should think of ways that you can optimize the time you spend with DANCAD3D (tm) by using the drawing editor manually for tasks that you need immediate visual feedback while doing, and by using macro command files for tasks that will require loading and manipulating many drawings in a pre-determined process.

You should try to use a macro to do your time consuming tasks like printing drawings out while you are away from your computer. After all, computers should give you more free time, therefore you might set up a macro that will run for days or even weeks, and come back to find all your work completed automatically. Be aware that leaving your computer, printer, and other equipment unattended can pose a fire risk so act accordingly.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Example Macro files.

Associated with this document, or the program files, you may find some files that have the filename *.MAC, or sub-macros may have the extension *.SUB. Check SECTION: 9 to see if there are any example macro files you can download. If you cannot find the example macro files, you can try to make some using the output macro feature in DANCAD3D (tm).

Example macro files made for different versions may not work the same other different versions. When testing macro files be sure that the macro file was written using the macro commands of the program version that you are testing, and that all of the needed files have been installed in the right sub-directories.

The example macro command files have been chosen to provide examples of some of the more specialized commands. However the bulk of the macro code is made up of the most commonly used macro commands, i.e. LOAD, SAVE, DISPLAY, ROTATE, OFFSET, and MAGNIFY. After you become familiar with DANCAD3D (tm)'s macro syntax and style you may be able to write your own macro files in this same style.

This section is not intended to explain the macro commands used since the individual macro commands are explained in the other *.HTM files (look for Appendix B), but rather to provide examples of how the macro commands can be arranged in a purposeful order to do some tasks automatically.

To follow along while reading the example macro files the reader can draw on his experience from using the DANCAD3D (tm) menu commands to form a mental image of the action that will be taken on the elements in the workspace when the macro commands are executed with the [R]un command. As you read along the flow of commands in the example macros you should be able to see how the elements will be manipulated in your minds eye. If you have difficulty visualizing the effect of commands on the elements try inserting a DISPLAY command between all of the commands in the macro and leave the macro debugging trace on so you can read the commands roll by as you watch the display of the workspace on the computer screen. Use the trace delay to slow the trace on fast computers.

When you want to run any of the example macro files you will need to copy all of the associated sub-macros and data files along with the main macro to the DANCAD3D (tm) sub-directory in order for the main macro to be able to find the associated files.

Some of the example macros may have a flag variable, e.g. LET |MODE = 0, in them that allows the macro to run in two, or more, ways. For testing the flag variable would be set to the value given in the adjacent comment that indicates the value will cause the macro to use the ANIMATE command for display of the pixel frame files stored on your harddisk. If you wish to output the animation to a cine film recorder rather than the harddisk the mode flag variable might be set to some other value that is indicated in the adjacent comment (if there is one). The number of frames in each animation cycle can usually be altered, but you should read through the macro to be sure that the value for the number of frames and cycles, that you desire, will be compatible with the way the macro operates. Not all the example macro files make animation, but the macros may still have variables named MODE, or something else, that change the output.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Macro code syntax overview.

In order for macro files to work properly you need to arrange the macro commands in the proper sequence, first to be done at the top down to last to be done at the bottom. There are also some details in the use of punctuation and spacing that need to be observed. Certain symbols and spellings of words are reserved and have special meaning when used in macro code text files.

If you edit a macro file with some external text editor, that is one other than the [W]rite command in DANCAD3D.COM (tm) or DANCAD87.COM (tm), you should save the macro file from that text editor as a plain DOS *.TXT text type file with the extension *.MAC. You might rename the macro file from *.MAC to *.TXT and to *.MAC if such is needed for the text editor to load and save the file properly.

The first macro command must be the macro VERSION command. This must be on the top line of the macro so that the program can identify the macro file's command version level.

You cannot use the reserved words and symbols in the wrong places without having your macro crash or do the wrong thing. The names of any files on your harddisk should be considered reserved words, and should not be used in your macros unless you actually want the macro to read or overwrite that file.

The text below, and the text elsewhere in this document, goes into some of the ways, and particulars, about how macros can be written.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Macro code syntax steps.

Key-Points relating to Macro syntax:

  1. The meaning of command names or "key words" are found elsewhere in this document (look for Appendix B).

  2. The macro must start with the VERSION macro command to set the macro code version level.

  3. You must leave a space character between all words, and numbers used in the macro files (words that contain symbols, like filename's with directory paths, should be written normally and preceded and followed by a space.)

  4. Use the number symbol (#) to select the element to act on before stating commands that act on specific elements in the workspace.

  5. Some commands like ENTER and ECHO have restrictions on the location of the parameter text, be careful to observe these restrictions.

  6. Use the macro TRACE command to check the amount of computer RAM memory free when you nest macro sub-routines. The commands that print drawings use more memory than most of the other macro commands so the printing commands should be used at the lower levels of nesting (to avoid an out of memory error or possibly a system crash.)

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Macro code syntax discussion.

What follows here is a quick review of DANCAD3D (tm) macro code syntax. For some more explanation please refer to Appendix B and Appendix C in this document.

As you know from your use of DANCAD3D (tm)'s menu commands DANCAD3D (tm) lets you manipulate drawings one element at a time or as a single mass of all the elements. It is important to remember that the select element number macro command MUST BE USED before any of the commands that can act on individual elements! The select element command is the number symbol, i.e. #. A space character must follow the number symbol to separate the number symbol from the number of the element. Variable names can be assigned to stand for element numbers.


EXAMPLE: # 3 ROTATE C 0 0 90
         # 2 MAGNIFY Z 0.707 0.707 1
         # 127 FLIP C Y
         # 99 SAVE 3D-QUICK C:\3D\MYFILE.99
         # |VARNAME SAVE ASCII SOMEFILE.ASC

When you want to act on all the elements in the workspace you still need to select the element to act on, but you select all the elements as the element to act on. To select all the elements as the element to act on use the element number zero (0) as the selected element number.


EXAMPLE: # 0 SAVE ASCII C:\TOOLPATH.ASC
         # 0 ROTATE Z 0 0 90
         # 0 MAGNIFY Z 240 240 240
         # 0 SAVE 3D-QUICK C:\3D\MYFILE.3D

The commands that always act on more than one element, or commands that have specific or implicit elements to act on, do not need to be preceded by the select element number symbol. Commands that create new elements do not need to have the element number to act on selected since the next element to be created will generally have its number become the highest element number. Commands that are not involved with the workspace also do not need to have element numbers selected for them.


EXAMPLE: SAVE ELEMENTS C:\3D\DWGDH.3DE
         JOIN 6 9
         LOAD ASCII C:\ASCII\TOOLPATH.ASC
         POLYGON 5 5 1.125 1 1 0 0
         SIGNAL 440 250

All the parameters that go with macro commands need to be stated. When you do not want to specifically change the current value of a parameter to a macro command repeat the current value or enter a neutral value. For the commands that ROTATE the value 0 will usually cause no change, and the value of 1 for MAGNIFY will similarly usually have no effect. When element center ZERO is used the rotations are absolute and therefore will always change to the values entered, when the element center CURRENT is used the change will be relative to the current value. The element center mode is usually abbreviated C or Z, for the elements CURRENT center point, or the workspace ZERO point. Magnifying by zero (0) will irretrievably squash the selected element (which can be useful if you only squash one of the three axes.)


EXAMPLE: # 3 ROTATE ZERO 0 0 90
         # 3 ROTATE CURRENT 22.5 -22.5  0
         # 0 MAGNIFY ZERO 2 2 2
         # 6 MAGNIFY CURRENT 0.707 1 0
         # 0 OFFSET ZERO 0.25 0 0
         # 7 OFFSET C -11.25 45 5.635
         # 0 FLIP Z Y
         # 9 FLIP C X

In order to manipulate arrays (sets) of elements that have been saved from the workspace to the harddisk DANCAD3D (tm) has a NAME command that will automatically generate a sequence of filenames with numbered extensions.


EXAMPLE: NAME 3 = C:\TRASH 0
         # 1 SAVE 3D NAME 3 HERE ; Makes file C:\TRASH.0
         # 1 SAVE 3D NAME 3 NEXT ; Makes file C:\TRASH.1
         # 1 SAVE 3D NAME 3 NEXT ; Makes file C:\TRASH.2

It may be possible to use the SAVE ELEMENTS and LOAD ELEMENTS commands along with the NAME command to make an array of up to 1098 sets of 999 elements.

Before the DISPLAY command can be used the macro command GRAPH or GRAPH_MODE must be used to set the graphics video mode. The macro command GRAPH is also used to clear the graphics screen so that a new drawing can be displayed.


EXAMPLE: GRAPH_MODE B&W
         LOAD PIXEL C:\PIX\FRAME.1

The macro command INITIALIZE should be used at the start of each macro file if you want the workspace to be empty when the macro starts to execute. You would also use the INITIALIZE command to clear the workspace after the elements had been saved to the disk or are no longer needed.


EXAMPLE: NAME 1 = PARTS 0
         :LABEL
           INITIALIZE
           LOAD 3D NAME 1 NEXT
           ROTATE C 180 0 0
           # 1 SAVE 3D NAME 1 HERE
         LOOP :LABEL 127

Macro program commands are read as a list from top to bottom and from left to right unless the GOTO, LOOP or RUN commands are used. The RUN command runs a sub-macro as was described above. The LOOP command is shown in the above example, where the code between the first occurrence of :LABEL and the second occurrence of :LABEL next to LOOP gets executed 128 times. A label is a marker in the macro code text and can have up to eight letters and must start with a colon (:) character. The GOTO command by itself will branch (redirect) the macro program execution directly to the label point. It should not need to be mentioned that you need to use a different label name for each new point in the macro file you want to branch to, i.e. each point in the macro code you mark with a label needs a unique name (you should keep this in mind, as duplicating labels can be a source of program bugs, e.g. if you block copy a section of code and forget to alter the additional label's name.) The GOTO command has a special form known as IF THEN GOTO that allows the branching of the flow of the macro execution to be conditional to the value of some variable.

When you mark a point in the macro code with a label you cannot mark another point with the same label name, you must use another name for the other labels. When a label name is used with the LOOP or GOTO commands the label name after LOOP or GOTO is not a label for a place in the program, but is used to tell DANCAD3D (tm) what label to look for in the macro. When GOTO is used the label can be before or after the GOTO command, and more than one GOTO command can reference a particular label.


EXAMPLE: LET |ALPHA = 45
         :POINT1
           # 0 ROTATE Z 0 0 |ALPHA
           LET |ALPHA = |ALPHA + 1
         IF |ALPHA <= 90 THEN GOTO :POINT1

DANCAD3D (tm)'s macro code supports variables and the evaluation of equations. The LET command must be used to initialize a variable before the variable is used as a parameter to a command key word. An unlimited number of variables can be stored on disk drives when the variable name is a valid filename (be careful that filenames used for variables are not the name of some important file since the program does not ask any questions before over-writing variable files.) You can store and retrieve a few frequently used variables more quickly in the computers RAM if you use variable names up to eight characters preceded by the vertical bar character i.e. | (the ASCII number #124), as the variable name. That is, |VARNAME will be stored in RAM and just VARNAME will be stored on your harddisk. Equations to be evaluated must be enclosed within square braces, i.e. [ and ].


EXAMPLE: LET C:\VAR1.56 = [ SIN( |ALPHA3 / 1 ) + RAD( 45 * |J ) ]

Some of the example macro files may have been written before the RAM scratch pad for storing variables was added to DANCAD3D (tm)'s resources. If you edit the macros that do not use the RAM for variable storage and add the | character in front of the variable names the macros may run faster. Some of the variables in the example macros may need to be saved to disk and should not be put in the scratch pad, e.g. for a main macro to communicate with a sub-macro and such. If you leave the macros as they come in the distribution for the version of the program you have the macro files should work on the first try. Macros written for one version may not work on other versions because of changes to how some of the commands operate, see the description of the VERSION macro command in Appendix B.

You will notice comments inserted into the macro code. Inserting comments into the macro code helps to be able to remember what you were trying to have the code do. There are two ways to make a comment, you can put a semicolon (;) in front of a comment that extends to the end of the line, or the comment can be between curly braces, i.e. { and } so that another command can be on that line of text. Comments are not allowed on the text line for the LETTERING command, after ECHO, inside the ENTER command, or between parameters assigned to a command.


EXAMPLE: # 1 FLIP C X  ; This is where a comment would go.
         LOAD 3D FILENAME { or here } ECHO LOADING FILE

The curly braces, i.e. { and }, can be used to "block off" a portion of a macro, so that that portion will be skipped over when the macro is run.


EXAMPLE: # 1 FLIP C Y ; This will execute.
         {
         # 1 FLIP C X ; This will not execute.
         # 1 FLIP C Z ; This will also not execute.
         }
         # 1 MAG C 1 2 1 ; This will execute.

Other aspects of writing DANCAD3D (tm) macros are simple extensions of normal programming practice common to all programming languages. DANCAD3D (tm)'s commands are tailored specifically to the manipulation of elements and drawings, and therefore take care of all the small details of opening and closing files for you automatically. Be sure to look in the other parts of this document of more information on the many commands in the DANCAD3D (tm) macro language.

The easiest way to learn how to fit together DANCAD3D (tm)'s macro commands is to study the macro code examples, and any *.MAC file. Studying a complete macro is more informative of structure and usage than looking at short program fragments.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Overview of using Macros in Engineering.

Engineering implies the development of a new mechanical system, rather than the construction or manufacture of an existing design. The ability to write macros for DANCAD3D (tm) to make animations (simulations) of mechanical systems might let you "try out" your designs before you go to the trouble of building the prototype. After the design is finalized you might write a macro to be used to create tool path files for use with DANCAM.EXE (tm) or DANPLOT.EXE (tm) to manufacture your prototype. If the prototype is not what you needed you would edit your macros to alter the design for the simulation and production of the tool path files.

Always carefully look at and examine any tool path generated by a macro, since a bug in your macro or DANCAD3D (tm) might make a defective tool path. A defective tool path could damage your machine, or produce injury, as well as waste material and time.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Steps for using Macros in Engineering.

The steps to write a Macro are:

  1. Write macros to create elements of the parts you have designed such that the outlines will allow you to visualize the parts in an animation of your system.

  2. Write a macro to animate your mechanical system elements to check for interference throughout the range of motion.

  3. Use the ANIMATE command, or a cine film recorder to view the animated simulation of your system.

  4. Write macros to create the necessary tool path cycles to manufacture the parts needed.

  5. Use DANCAM.EXE (tm) or DANPLOT.EXE (tm) to manufacture the parts.

  6. Repeat steps 1. through 5. as needed to improve the design.

  7. Use DANCAD3D (tm) to make drawings of the final design.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Uses of Macros in Engineering.

In general writing macros for use with DANCAD3D (tm) will make editing and repeating tasks easier. There are several uses of macros that will be helpful in engineering mechanical systems:

Points where Macros make editing easier:

  1. Generate elements for animations.

  2. Animate elements for visual display.

  3. Make interactive macros to generate tool path files.

  4. Make macros that alter tool path files from a DOS batch file.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Generating elements.

DANCAD3D (tm)'s mathematical capabilities allow the use of formulas in the creation of elements in DANCAD3D (tm)'s workspace. In general the macro APPEND command would be used to append line segments one point at a time while the formula is solved for a variable, e.g. solve x for y, or solve x and y for z.


EXAMPLE:  VERSION v2.7A
          ; BEGIN FORMULA1.MAC REV Y2002-M05-D11

          INIT

          LET |STEP = 0.1

          LET |XINIT = -2
          LET |YINIT =  0

          LET |X = |XINIT
          LET |Y = |YINIT

          BEGIN

          :LABEL

          IF |X = |XINIT THEN GOTO :SKIP
          IF |Y = |YINIT THEN GOTO :SKIP

          APPEND |OLDX |OLDY 0 |X |Y 0  1 1 0 0

          :SKIP

          LET |OLDX = |X
          LET |OLDY = |Y

          LET |X = [ |X + |STEP ]
          LET |Y = [ ( SIN( |X * 2 ) + COS( |X * 5 ) ) / 2 ]

          IF |X <= 2 THEN GOTO :LABEL

          # 1 CURVE_FIT O Y 5 0.2
          # 1 SAVE 2D_REAL 0 0 0 -1.0E+18 380 1 0 0 FORMULA1.2D

          INIT
          WORLD 240
          LOAD 2D FORMULA1.2D
          # 1 LINETYPE 2 1 0 0
          WYSIWYG 1
          PALETTE 1 0 0
          GRAPH_MODE COLOR
          # 1 DISPLAY 0 0 0 -1.000E+18 1 1 0 0
          ECHO Press [Return] to continue...
          WAIT

          ; END FORMULA1.MAC

In the above FORMULA1.MAC the CURVE_FIT command is used to speed up the macro by calculating points farther apart (|STEP sets the distance between the points) then filling in more points to make the curve smoother.

The macro commands BETWEENS, EXPAND, and CURVE_FIT can be used to generate contoured surfaces and other shapes that cannot be made with circles and straight lines.

Don't forget to use the automatic output macro feature whenever you draw an element with DANCAD3D (tm). If you make an output macro you will be able to edit the output macro to make changes without having to redraw the elements. If you need to use the editing commands in the drawing editor to alter your elements, turn on the output macro feature and Append the changes you make in the drawing editor to the previously output macro commands already in the macro file of your drawing, so that the output macro has all the changes made to the elements recorded.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Animation in Engineering Simulations.

The details of animation are covered in the example macro code in some of the example macro files. Here I will outline some of the basic concepts used.

To make an animation you will generate (draw) a series of elements that represent the mechanical system's parts. You then write a macro to move and rotate the elements in the ratios that the actual parts will move and rotate. The amount that the parts move from one drawing (frame) to the next is determined by the fastest moving part. The amount of movement from one frame to the next for the fastest moving part will need to be small enough to allow the regions of possible interference with other parts to be seen in the display, e.g. the fastest shaft might turn 5 to 10 degrees per frame.

When analyzing mechanical systems you should look for cyclic motion that repeats. In some systems such as gear trains you do not need to cycle through the full motion of the slowest gear, but rather only through the movement of one tooth of the slowest gear. By taking advantage of the repeat inherent in the ANIMATE command you can get the impression of continuous motion. When making a cine film you can repeat a cyclic motion by making a nested loop (see the information on the LOOP command.) Nesting cycles of motion can reduce the number of data files you need to save for complex animations, e.g. save each gear's motion for only one tooth, and nest loops such that the smallest gears cycle repeats at the highest frequency.

Use the macro commands ECHO and OUTPUT to display the values of rotation angle and displacement distance of the elements in the simulation so that you can read the critical values off the screen while the animation is displayed. The animation macro can be stopped at critical points, with the macro STOP command, and the distances and angles of the elements in the workspace measured with the drawing editors [M]easure command. The values of measured qualities can then be used to make decisions about the need to alter the shape of the parts (elements) in the system.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Interactive Macros.

Rather than use DANCAD3D (tm)'s [W]rite command every time you need to change a macro's variables values, you can use the macro commands ECHO, INPUT, and INPUT$ to have the macro ask the user questions about the values to use.

You can write general purpose macros that will make up tool path files. Such a tool path macro might ask questions such as the diameter of the mill, the position and size of the pocket, and the feed per cut. After the values are entered into the macro the other macro commands would calculate the number of cuts required, use nested loops and the APPEND command to generate the required element, and then the SAVE ASCII command to save the finished tool path file.


EXAMPLE:  VERSION v2.7A
          ; Example of variable input and nested loops.

          INIT

          INPUT |XSTART
          INPUT |XEND
          INPUT |XFEED
          INPUT |YSTART
          INPUT |YEND
          INPUT |YFEED
          INPUT |ZSTART
          INPUT |ZEND
          INPUT |ZFEED

          LET |Z = |ZSTART
          :ZLOOP
           LET |Y = |YSTART
           :YLOOP
            LET |X = |XSTART
            :XLOOP

            { Use the values of |X |Y and |Z here to make the path. }

            LET |X = [ |X + |XFEED ]
            IF |X <= |XEND THEN GOTO :XLOOP
           LET |Y = [ |Y + |YFEED ]
           IF |Y <= |YEND THEN GOTO :YLOOP
          LET |Z = [ |Z + |ZFEED ]
          IF |Z <= |ZEND THEN GOTO :ZLOOP

          # 1 SAVE ASCII NAME 0 INPUT

          ; END

Macros that prompt the operator can be useful when a macro is automatically run from a DOS batch file, and you want DANCAD87.COM v2.7A (tm) to put up a menu that will alter what the macro does. If the filename made by the macro for use with DANCAM.EXE (tm) is always the same the batch file will not need to be altered. Here the version v2.7A level macro command HALT would be the last macro command in file MYCAMMAC.MAC for DANCAD87.COM v2.7A (tm).


EXAMPLE:  REM Example DOS batch file for DANCAD87.COM v2.7A (tm).
          DANCAD87 MYCAMMAC.MAC
          DANCAM FILENAME.ASC
          REM End of example DOS batch file.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

Using Macros to alter tool path files.

If you want to repeat an operation on all your tool path files before you save them for use, you can make a macro file that you can [R]un before you save the whole tool path.


EXAMPLE:  VERSION v2.7A
          LET |SPACE = 1.75
          # 1 COPY
          # 1 COPY
          # 1 COPY
          # 2 OFFSET C |SPACE 0 0
          # 3 OFFSET C [ |SPACE * 2 ] 0 0
          # 4 OFFSET C [ |SPACE * 3 ] 0 0
          # 0 SAVE ASCII TEMP.ASC
          INIT
          LOAD ASCII TEMP.ASC
          # 1 COPY
          # 1 COPY
          # 1 COPY
          # 2 OFFSET C 0 |SPACE 0
          # 3 OFFSET C 0 [ |SPACE * 2 ] 0
          # 4 OFFSET C 0 [ |SPACE * 3 ] 0
          JOIN 3 4
          JOIN 2 3
          JOIN 1 2

The example makes 16 copies of a tool path, arranged 4 by 4, spaced 1.75 units. This could be used if you have a fixture that holds 16 parts to be machined as a batch job.

A DOS batch file can be used to activate DANCAD87.COM v2.7A (tm) and a macro file in order to OFFSET a tool path file between cuts. A series of interactive or preset macro files can be activated from a DOS batch file to make changes to the tool path files at various points in the manufacturing process. Use the macro command HALT version level v2.7A at the end of the macro files to force DANCAD87.COM v2.7A (tm) to automatically return control to the DOS batch file.


EXAMPLE: REM  This is a DOS  batch  file.
         DANCAD87 PATH1.MAC
         DANCAM PATH1.ASC
         DANCAD87 OFFSET1.MAC
         DANCAM PATH1.ASC
         DANCAD87 OFFSET2.MAC
         DANCAM PATH1.ASC
         DANCAD87 PATH2.MAC
         DANCAM PATH2.ASC
         DANCAD87 OFFSET3.MAC
         DANCAM PATH2.ASC
         DANCAD87 OFFSET4.MAC
         DANCAM PATH2.ASC
         ECHO OFF
         ECHO THIS JOB IS DONE...
         PAUSE

The reason for manipulating the tool path files rather than just making a single tool path that has all the cutting drawn out is that the ASCII tool path files can get very large, in some cases larger than your harddisk. If you create and erase the tool paths from macros as need the work will go slower, but you will not have to store large files.

Generally when milling contoured surfaces you can repeat the same tool path file over and over feeding on one of the axis between each cut. The feed on the third axis would be introduced as in the above example batch file. To maximize the speed of cutting you should try to have the line segments as long as possible in the tool path files for the rough cuts. You can change the parameters to the POLYGON, CURVE_FIT, EXPAND, and BETWEENS commands to make the line segments in the rough cut tool path file longer than the line segments in the final cut tool path file, to speed up the cutting of the rough cut. The maximum speed difference between long and short lines is not as important on faster computers, since both would be faster than the maximum feed rate the tool can cut at.

A typical macro to offset a tool path file would load the tool path, offset the element in the workspace, and save the offset tool path.


EXAMPLE: VERSION v2.7A
         ; OFFSET1.MAC for DANCAD87.COM v2.7A
         LOAD ASCII PATH1.ASC
         # 1 OFFSET CURRENT 0 0 0.003
         # 1 SAVE ASCII PATH1.ASC
         HALT

A variable saved on the harddisk might be used to keep track of the total offset, or the number of times the tool path has been offset. One macro would be used to set up the variables on the harddisk (no | in front of the variable name saves the variable on the harddisk and allows the value of the variable to exist (persist) to be read the next time DANCAD87.COM v2.7A (tm) is run) and another macro would be run alternately with DANCAM.EXE (tm) until the total feed was achieved. The set up macro could use the INPUT command to ask for the feed and limit amounts. When the limiting value was been reached and the test in OFFSET.MAC branches to the STOP command and returns you to DANCAD87.COM v2.7A (tm)'s main menu the computer should be rebooted (by pressing [Ctrl] & [Alt] & [Del]) to prevent the batch file from picking up if you to exit DANCAD87.COM v2.7A (tm) manually. If you are going to reboot from inside DANCAD3D.COM (tm), you should probably add the commands CHKDSK /F and DEL FILE????.CHK to your AUTOEXEC.BAT file, or run them manually after re-booting your computer. You would also need to DELETE the program running flag file DANCADXX.RUN before trying to run any of my programs since re-booting while DANCAD87.COM v2.7A (tm) is running will not automatically erase the DANCADXX.RUN file and you will get an error message the next time you try to run the program, or one of my other v2.7A programs in the same sub-directory.


EXAMPLE: VERSION v2.7A
         ; SETUP.MAC for DANCAD87.COM v2.7A
         LET FEED  = 0.003
         LET TOTAL = 0
         LET LIMIT = 0.036
         HALT
         ; END


EXAMPLE: VERSION v2.7A
         ; OFFSET.MAC for DANCAD87.COM v2.7A
         LOAD ASCII PATH.ASC
         # 1 OFFSET CURRENT 0 0 FEED
         LET TOTAL = [ TOTAL + FEED ]
         IF TOTAL <= LIMIT THEN GOTO :CONTINUE
         TEXT
         ECHO JOB DONE, Turn off the tool power
         ECHO and then press [Ctrl] & [Alt] & [Del]. %%
         WAIT
         STOP
         :CONTINUE
         # 1 SAVE ASCII PATH.ASC
         HALT
         ; END


EXAMPLE: REM This is a DOS batch file with a loop in it.
         DANCAD87 SETUP.MAC
         :LABEL
         DANCAM PATH.MAC
         DANCAD87 OFFSET.MAC
         ECHO Press [Control] & [C] to break this batch file.
         ECHO .
         ECHO .
         GOTO :LABEL

From the above brief descriptions you might see that macros can be useful in a number of different ways to you while you test the programs. The macro source code in the examples for this version should help you figure out which macro commands to use and how to arrange the macro commands to perform different tasks. See also Section: 9 for any example macro files you can download, and look at the other example macros in the document text.

Click here to go to the Macro Keywords A to Z list.
Click here for more information about Appendix B.
Click here for more information about Macro Math and Strings.
Click here to go back to the top of this page.

TERMS OF USE, HOME, INDEX, SHORTCUT, WHAT'S NEW, DOWNLOADS, GET MAIN ZIP, DOCUMENTATION, VIDEO, HOOKUP#1, #2, #3, KEYWORDS

WWW.DANCAD3D.COM (sm): THE OFFICIAL DANCAD3D (tm) "BETA TEST" WEB SITE.

This copy of this page was compiled on or around: Y2008.M05.D14, you might check the "On-Line" version, or come back later, to see if there is a newer compile.