Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HELP! AutoCAD LT polyline macro

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
OAllington
3212 Views, 18 Replies

HELP! AutoCAD LT polyline macro

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

 

18 REPLIES 18
Message 2 of 19
pendean
in reply to: OAllington

>>>...line is drawn and the command is finished...<<<
In macros writing, you'd have to second guess how many lines will need to be drawn so you can then "finish" what you need to complete.

Q: your macro(s) select the "last" object before they start drawing a new PLINE, so you seem to always be taking action on already drawn plines. Could that be the flaw you are trying to fix, your backwards macro?
Message 3 of 19
OAllington
in reply to: pendean

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?

Message 4 of 19
pendean
in reply to: OAllington

Yes, with macro writing, you will need to guess how many clicks a user will use. It's why you want to avoid placing basic drawing tools in macros.

Q: why do you need PLINE in a macro, are you not able to just start drawing with PLINE, finish whenever you want, then use the macro to do everything else? Just a thought.
Message 5 of 19
steven-g
in reply to: OAllington

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;
Message 6 of 19
Paul_Gander
in reply to: OAllington

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.

Message 7 of 19
steven-g
in reply to: Paul_Gander

I'm impressed! certainly gets my vote, I shall enjoy deciphering the code when I get a spare half hour. 

Message 8 of 19
Paul_Gander
in reply to: steven-g

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.

Message 9 of 19
steven-g
in reply to: Paul_Gander

And have you come across this site in your adventure combining cal with diesel can be a real headache but powerful.

cadingandcoding.blogspot.be

Message 10 of 19
john.vellek
in reply to: OAllington

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


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
Message 11 of 19
steven-g
in reply to: john.vellek

@john.vellek take a look at the post from @Paul_Gander it does the job perfectly.

Message 12 of 19
OAllington
in reply to: Paul_Gander

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

Message 13 of 19
OAllington
in reply to: OAllington

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

Message 14 of 19
steven-g
in reply to: OAllington

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.

Message 15 of 19
pendean
in reply to: OAllington

In Addition to Steven's reply, you can usually repeat a macro you activated with a button or menu selection with a right-light then reselecting it from the top of the command list presented.
Message 16 of 19
Paul_Gander
in reply to: OAllington

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.

Message 17 of 19
steven-g
in reply to: pendean

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).

Message 18 of 19
JLJZPWBF
in reply to: steven-g

Actually, you can repeat the macro. You just need to add an * in front of the macro.

Message 19 of 19
JLJZPWBF
in reply to: JLJZPWBF

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report