News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Macro Understanding

Started by wisoak, October 05, 2017, 11:32:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wisoak

My hat is off to the many DesignCad users that understand the use of macros....but for many, and maybe the majority of DC users, reading in this Forum how to insert a new macro or modify an existing macro.... is Greek to us and has no value in fixing the problem that I and others might also be experiencing. Our biggest fear is that, "if we attempt to install a macro or attempt to modify the DC program using a macro, a program "crash" is eminently inherent, causing greater problems than the original problem.

My questions related to this are:
1. Does the IMSI team keep track of all the problems fixed by user defined macros and are they implemented in the updates?
2. Is there a "Macros 4 Dummies" thread on this forum that might ease our inabilities?

I'm currently a user of V24, but have been using DC3D since the early 90's.
V24.0

Pearco

wisoak;

If you go to the home page of this forum you will find a section with the heading of DesignCad SDK. There you will find a lot of discussion of BasicCad and other program languish that will work with Dcad. It is a good source of information about macros also.
Jim
User since ProDesign 1.5

Lar


Wisoak, macros do not alter dcad's code in any way and neither are they ever installed (so they are not "plug-ins"). They are simply external text files that gives dcad instructions on what to do.


Macros are normally written to follow the same process a user would carry out to achieve a certain result, but at computer speed rather than human speed. Also, they can use variables so a common task can be carried out with different parameters. Eg, a macro can be written to draw a staircase but it will ask you to supply the riser height. Once you do this (and maybe set a starting point or two) it will draw the staircase for you according to the value you input for the riser.


Lar

Rob S

One of the best ways to learn the macro language is to record a macro that does something like what you want, and then edit that macro according to the ends you want to accomplish.

Macros can be created and edited using notepad, and you can cut and paste from the forum, from the instructions, and from your recorded macros.  Only thing is, you need to tell notepad not to add the txt extension by putting  "Macroname.d3m" in quotes.

I usually save my macros in the sample macros folder that comes with designcad, and make sure the macros folder is set to that under options, file locations

That way, once you have created your macro, you can run it by hitting the spacebar, typing its name, and enter.  Documentation downloads can be found here..   Get the one for v17 to start.

http://forum.designcad.com/index.php?topic=1537.0
User since forever

Dr PR

wisoak,

The real question is whether or not you want to take time to learn programming?

Like Lar said, macros are just a set of text instructions. DesignCAD's macro feature reads and interprets the instructions, just as if you were typing them in on the keyboard.

But macros are written in a programming language, and if you have never written a program before the BasicCAD language can be confusing. And there are a LOT of unexplained things in the macros and macro help files that you are just expected to know. And if you have never programmed you will not know these things and the experience will be very frustrating.

I have been writing programs for 41 years, in at least twelve different programming languages, but many of the common programming concepts I am expected to know are implemented differently in every language, and BasicCAD is no exception!

I use a few macros in DesignCAD, mostly those written by others. But it usually takes more time to write and debug a macro than it takes just to do the job with ordinary DesignCAD commands.

There are some serious shortcomings with macros.

1. Macros cannot be executed from within a DesignCAD command. For example, if you are drawing a line and have set several points, and you try to execute a macro the line drawing function will be terminated. This severely limits the usefulness of macros.

2. Macro execution is relatively slow. DesignCAD has to read the macro command, translate it into a sequence of operations, and then call the machine code routines to process the text commands. It is a LOT slower than just running the machine code without all the other work.

I say "relatively" because short macros will execute quickly in a small drawing on a fast machine (it isn't nearly the problem we had 25 years ago on 12 to 20 MHz machines). But if you execute a macro in a large drawing, where the macro has to search through every object in the drawing, it may take hours to execute, even on the fastest machines. This is not an exaggeration! On my 3.7 GHz six core i7 machine the simple "group count" and "solid count" macros have run all night with 300-400 mbyte drawings! I have started the macros before I went to bed, and when I woke up eight hours later they still had not finished. In fact, I have never allowed them to finish so I really don't know how long it would take for them to execute - I just restart the program so I can get some work done. For a comparison, the built in "Pack Group IDs" and "Pack Solid IDs" commands (machine code) have to find and modify every group and solid in the drawing, and they execute in a matter of seconds. Well, "Pack Solid IDs" sometimes takes up to a minute in a drawing with about 100,000 solids.

My point? Macros aren't a solution to all problems, and can be problems in themselves.

Others here will disagree. They have spent many hours creating, debugging and implementing dozens of macros. For some just creating another macro is a goal.

But do you want to spend a lot of time messing with macros, or do you want to create drawings?

Phil
DesignCAD user since 1987

Bob P

Dr PR's ship is very impressive, but I've been using DC for 20+ years and, out of thousands of drawings, I have fewer than 20 that are larger than 5mb, and none are bigger than 20mb. Waiting for a macro to execute has never been a problem for me.  On the other hand, searching through menus for a command has always taken too much of my time (and brain memory), so I get around that with macros for almost everything, but I am a comfortable touch-typer.

Dr PR

Bob,

I guess my comments must seem overly pessimistic, so I should say that macros are one of DesignCAD's exceptional features. The ability to place a macro in a menu, assign it to a hot key or put it in a tool box is VERY useful. I do use macros!

Macros are extremely useful for operations that you repeat frequently. You can execute several commands with a single operation. For example, I use the vc.d3m macro all the time. It sets the View Center where the cursor is and then starts the "Set View by View Center" function that orbits the view around the view center. In fact, I have assigned the macro to the "Y" key, replacing the "Set View by View Center" function for that key.

Without it I would have to execute the "Set View Center" function and then the "Set View by View Center" function. The latter is useless by itself because it orbits the view around some unknown place in the drawing that may be far away from what you want to see.

The operating speed issue is related to the number of objects in a drawing, and that generally relates to file size. The key thing to remember is that macro operating speed is related to the inverse of the number of objects it has to work on:

     1
______
objects

This is non-linear function, so if you double the number of objects the macros takes four times as long to execute. Just don't create or use macros that have to look at everything in a drawing and then use them in large drawings.

For me the biggest limitation is the inability to use a macro inside another command. For example, I can't use the vc.d3m macro to rotate the view around a specific point while drawing objects in 3D. Most of the time this is exactly when I need to use the macro!

Phil
DesignCAD user since 1987

wisoak

Thanks, Dr. PR. You said what I probably needed to hear. I would rather spend my time on my 3D drawings than experiment, fail, experiment, probably fail again, maybe spending hours to save a minute with a new macro.
V24.0

Bob P

#8
Wisoak,

Designcad has several ways to get things done, and macros are just one of them. Scroll down this page to download a list of all the shortcuts / shortcut keys. Almost all important commands can be done without resorting to the menus.
http://forum.designcad.com/index.php?topic=30.0

You can also change the default hotkey assignments, plus you can assign a hotkey to a command currently not listed. Options>keyboard  If you use DC a lot, you can make it your own.

Dr PR

I agree completely with Bob. The thing I like most about DesignCAD is the extreme flexibility of the user interface. You can change the program to work the way you want it.

For example, the "Make Plane" function is buried many layers deep in the menus, and I found that to be very annoying (I want to spend my time drawing, not opening menu after menu). So I assigned "Make Plane" to a custom tool, and put it in a custom toolbox. I also have "Contour Line" and "Angle between two lines" in my custom tool box, along with a tool to open the Windows charmap.exe program so I can copy symbols into text strings. I used the custom toolbox because these are functions I do not use very often, and I would forget a hot key combination. But they are always visible and accessible with a single click from the custom toolbox.

I use "Intersect 2" very often, so I assigned it to the "Alt X" key combination - that made sense to me. When I first started using DesignCAD (Prodesign back in those days) I could never remember the hot key combination for "Midpoint" because it made no sense to me, so I reassigned it to "CTRL M," and that is still what I use. I use several other custom hot key combinations. Once you have assigned your custom key s they will appear in the menus beside the commands.

But if you do have a sequence of commands you repeat often it may be worth your time to create a macro, like Lar's staircase example. Back in the 90s a fellow I work with wrote a macro to create instrument faces to print out and paste on the face of milliammeters so he could create custom instruments to read in whatever units he wanted (a logarithmic firkins per fortnight meter?). It took him a while to get the macro to work right, but afterward he could do in seconds what it would take an hour or two to do manually. You can assign your macro to a custom tool or a hot key, or add it to a menu.

And if you prefer to do as much as possible with the keyboard, you can type everything into the command line.

Phil
DesignCAD user since 1987

Lar

#10

You can't beat macros. Here's a simple example:
   One thing that irritates me (who typically uses hundreds of layers) about dcad is to make a layer current you have to open either the layer dialog or the layer toolbar's list and scroll to the layer (you can also use the same-as finger in the toolbar but that's only if a visible entity resides on that layer). And you will scroll pass that layer back and forth a few times before you find that layer. And what if the filter is set to 'active only', I will have to take the extra step of changing the filter. So what did I do, back in 1990-something? I took a few minutes to write and test a macro where I just type in the number of the layer I want current. This also bypasses that irritating message informing me that a layer that was just off is now on.


I was very happy with that macro for a decade or 2 until I became very irritated that my layer toolbar keeps forgetting that it's supposed to be on when using the 'hide/restore toolbars' command. So what did I do? I enhanced my 'current layer' macro so that I can select an object that I know is on the layer I want current, run the macro and if I just click ok without typing in anything the layer of the selected item will become current.


Even later, after finding myself using the last few layers as utility layers (since I can just hit the 'end' key on the keyboard to access them in the layer dialog, so no scrolling) and having to turn them on often. So here's what I did: I enhanced the macro so that if nothing is selected and I 'ok' without typing in anything then layer 2000 will be current... but only if it was off. If it's on then 1999 will be made current... but only if that was off. If that was also on then 1998 will be made current. There, I've given dcad AI (artificial intelligence).


That's just one very simple example. I have hundreds of macros, many very simple, many very complicated, that I use on a regular basis, and many more I have forgotten I ever wrote.


Without macros dcad would honestly be unusable for me.


Lar

bdeck

#11
Quote from: Lar on October 09, 2017, 07:12:13 AMYou can't beat macros. . . . .Without macros dcad would honestly be unusable for me. 

Hear, hear.

Some simple operations cannot be performed without great difficulty, unless a macro is used. (eg progressive dimensions)
Some operations can be performed only with a macro.