So, I am currently working on a macro in AutoCAD 2014 LT to increase drawing efficiency for our company.
What I am essentially trying to achieve is the following:
1) Draw a polyline of an unknown amount of points (can range from 4 points to 10 points)
2) Fillet said polyline with a radius of 2
3) Set said polyline to one of a specific set of layers
We have around 9 layers that we will be putting these polylines on, so my intent was to make an individual macro command for drawing a filleted polyline onto each layer.
My first attempt was almost what I want:
*^C^Csetvar;filletrad;2;fillet;p;last;-layer;m;AnalogueVideo;c;Green;;;_pline
- The above works OK, but it needs an initial previously selected polyline in the drawing to work.
- This also leaves me on the layer that I make in the macro, ideally I would have my default layer set back to '0'.
My second attempt solved the layer setting issue (in this instance I have my 9 layers already set up in the template, so no layer creation is required):
*^C^Csetvar;filletrad;2;fillet;p;last;change;last;;p;layer;AnalogueVideo;;_pline
- The above still works OK, but as before, it needs an initial previously selected polyline to work.
- Whilst this version solved the layer issue, it created another issue - if I use this to create polylines on my 'AnalogueVideo' layer, if i were to then use another version of the macro for another layer, the last 'AnalogueVideo' polyline I drew will be changed to the second layer.
It seems to me that all my problems would be solved if I could pause for user input infinitely on the polyline command until the line is drawn and the command is finished.
However, I have had a look and this only seems possible in LISP?
Any help would be extremely appreciated on this.
Oliver Allington
Solved! Go to Solution.
Solved by Paul_Gander. Go to Solution.
My macro is indeed backwards, the reason I structured it in such a way is because I can't figure out how to pause for user input until I have finished the polyline command. Which is the main reason that this is such a problem.
Are you saying I should start with the polyline command, pause for user input for around 10 times (as a guesstimate for how many inputs the user will perform), and then proceed with the rest of the macro?
In a macro you can pause for user input as often as you want, the only drawback is you have to use that user input there is no way to quit early and have the rest of the macro carry on, it just stops at that point if you cancel out. So you have to trick LT sometimes, It really needs your layer being set to current first and relies on you not drawing close to other objects that use the same layer or it might swallow them up. You also need to press the enter or space bar every time after the first segment is drawn. So the sequence is
Start the macro click on the first point
click on a second point
and from there on you need to first press enter/space followed by the next point.
When you are done press escape to finish the macro. and if you want a closed polyline then draw your last point back to the first point, the macro will fillet eveything as you go along. and with a closed polyline you still need to press escape to exit the macro. It might take a few runs to get used to the enter click sequence without doing click enter.
But see what you think and adapt it to suit.
*^C^C^Cpline;\\;selectsimilar;l;;m;0,0;0,0;pe;m;p;;j;;;fillet;p;l;;r;2;
This macro / Diesel program will do what I think you are describing in your initial post. (Tested on LT 2013)
*^c^c$m=$(if,$(or,$(eq,$(getenv,pgm_c),0),$(eq,$(getenv,pgm_c),)),setenv pgm_layer "AnalogueVideo" pgm_c 5)$(if,$(eq,$(getenv,pgm_c),5),setenv pgm_c 0 layer t $(getenv,pgm_layer) u $(getenv,pgm_layer) on $(getenv,pgm_layer) m $(getenv,pgm_layer) pline \\"""$m=$(if,$(eq,$(getvar,cmdnames),PLINE), select l setenv pgm_c 10,setenv pgm_c end)""")$(if,$(eq,$(getenv,pgm_c),10),setenv pgm_c 0 pline \"""$m=$(if,$(eq,$(getvar,cmdnames),PLINE), pedit l j p select l setenv pgm_c 10,fillet r 2 p l setenv pgm_c end)""")$(if,$(eq,$(getenv,pgm_c),end),layerp ^csetenv pgm_c 0)
Right click, enter or space to end the polyline as you normally would. To close the polyline, pick back on the first point before ending. The fillet command will join it up.
Thankyou Steven. I learned about macrotrace from one of your posts and have found it invaluable. I recently came across Robert Freeman's 1997 arctext macro which inspired me to experiment with programming with diesel. I had always believed it wasn't possible.
And have you come across this site in your adventure combining cal with diesel can be a real headache but powerful.
HI @OAllington,
I see that you are visiting as a new member to the AutoCAD LT forum. Welcome to the Autodesk Community!
This sounds like an interesting issue. Can you attach a sample file so I can get an idea of the geometry you are working with in your process? Is there a reason you can't first create the first segment of a polyline and then run your macro? Are all of the points predetermined or do you need to select them on-screen?
@john.vellek take a look at the post from @Paul_Gander it does the job perfectly.
Hi Paul,
Thanks for getting back on this. When I initiate the command with by clicking the command (set up as a custom command), it works great. But when I go to repeat the command by pressing enter/space afterward, it prompts me for a variable name under 'SETENV'. Is there any way I can get this command to repeat correctly when I am using enter/space to repeat it? Or will I have to stick to clicking it to repeat it?
Also, I'm a bit of a rookie when it comes to Diesel macros, can you help me out on showing me where I can amend this macro to change the layer names and colours?
Thank you, your help is appreciated!
Oliver
Ignore this section:
"Also, I'm a bit of a rookie when it comes to Diesel macros, can you help me out on showing me where I can amend this macro to change the layer names and colours?"
I have found a solution which doesn't involve any amendment to the provided macro.
So my only trouble at the moment is the other point.
Thanks!
Oliver
A macro can't be repeated like that, it isn't a command. You can only start a macro by clicking on the button that activates it, wether that is a toolpalette or a ribbon or menu command, you can place a macro in many places, but only start them with a click.
Trying to repeat them as you would do with a normal command only repeats the last command that was used by the macro.
I have my right click customisation set up so that if I hold down the right mouse button for half a second it brings up a shortcut menu. There is an option to repeat the macro there.
Unfortunately I'm a lazy drafter, all my macro's reside on various toolpalettes and are never linked back to the CUI. Which is quick but apparently makes me miss out on a nice feature (unless there is something else playing a role - but right click only gives me the option to repeat setenv).
I didn't explain that very well, if you put a star in front of the ^C^C_ like *^C^C_ it makes the macro repeat indefinitely.
Can't find what you're looking for? Ask the community or share your knowledge.