AutoCAD LT
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Greetings. I am new to this forum, and I am in need of some programming assistance.
I am in the process of moving from ADT 3.3 to AutoCad LT 2013. I have numerous LISP rotines (created by former colleagues long since gone) driven by key strokes that are important for my productivity. I have figured out how to customize some LT keyboard commands to replace the LISP rotines, but I have hit a wall on some others, the most important being layer management. Could someone provide some guidance in how to code a macro to turn on and turn off certain groups of layers? A small sample of the layers would be:
p-dimen
p-doors
p-roomnames
p-stairs
p-text
p-walls
p-windows
I have many more layers, but if I can get one example, I think that I can create the rest of them.
It would be great to assign a keystroke(s) (e.g., "pon" for plan layers on) as I am familiar to this, otherwise, I'd be happy to change my behavior to use a button on a toolbar to toggle the layers on and off.
I am not a programmer and could use the help.
Thanks!
Solved! Go to Solution.
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Create a Script file. These are simple text files with the extension .SCR
Put in the following
-Layer OFF p-*
or
-Layer
OFF
p-*
NOTE
At the end of the first suggestion you need to put 2 spaces after p-*as these act as returns
If you use the second suggestion, you need to put 2 hard returns after p-*
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You can't "keystroke" scripts or menu macros, in the AutoCAd shortcut sense of the word that is: just so you know.
The tip above is excellent as a script, it can also be written as a menu macro (Ribbon or Toolbar button, your choice):
^C^C_-Layer;OFF;p-*;;
A Semi-Colon, better than a blank space, acts like striking <enter> on the keyboard. ^C^C kills any running commands or object selections.
Macros are nothing more than an automation of what you can type at the command line in AutoCAD: there is no "lisp" intelligence to it and no keyboard shortcuts to invoke them. Know your commands, especially the commandline versions of the commands you want, and you're prety much 90% there for macro writing.
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks to you both for your input. I'll give this a try and probably assign it a button since I can't use keystrokes to invoke the script. BTW, I assume that I will need to create two scripts/buttons, one to turn on and one to turn off. It would be cool if only one button was required and it toggled the layers on and off. Is this a possibility?
Cheers!
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
DesCap wrote:... BTW, I assume that I will need to create two scripts/buttons, one to turn on and one to turn off. It would be cool if only one button was required and it toggled the layers on and off. Is this a possibility?
It depends, are you just looking to turn on and off layers? See sample macro:
^C^Csetenv;layon-off;\$M=$(if,$(=,$(getenv,layon-off),1),turn-layers-on,turn-layers-off)
Put your macros to turn on and off the layers in the appropriate places.
(if ("mysolution"=answer) then (click "Accept As Solution"))
--------------------------------------------------
Brandon Gingerich
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I would be looking to turn on and off certain groups of layers (e.g., floor plan layers as referenced above) with a single button. Where in your script would you place the "^C^C_-Layer;OFF;p-*;; " script noted above? Sorry if this is the answer to this question is obvious, but I am out of my comfort zone here.
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try this:
^C^Csetenv;layon-off;\$M=$(if,$(=,$(getenv,layon-off),1),_-Layer;ON;p-*;;,_-Layer;OFF;p-*;;)
Type either 0 or 1 at the prompt and it should do the rest for you.
Do you understand the gist of what is going on? If not I can try to explain what is happening in this macro.
(if ("mysolution"=answer) then (click "Accept As Solution"))
--------------------------------------------------
Brandon Gingerich
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Do so please, I think that would be good for anyone who comes across this.
(Of course when you have the time that is.
)
CSHADEDESIGN|AUTOCAD LT|LT-KB|DYNAMIC BLOCKS
Please mark Accept as Solution if your question is answered. Kudos gladly accepted. ⇘
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Are you just too lazy to do it yourself, Charles? ![]()
Anyway, the basics of this macro... First it creates/modifies an environment variable with a value that the user supplies (should be a 1 or 0). The fancy '$(' s all over the place are Diesel expressions which can be found in the Help docs; the $M= tells Acad that a menu/Diesel macro is coming up and not to treat it as text for the command line.
$(if,$(=,$(getenv,layon-off),1),...,...)
This is just telling Acad, "If environment var 'layon-off' is found and has a value of 1, do the stuff in between the second and third periods and if it isn't do the stuff in between the third period and the right paren ")".
If "layon-off" equals 1, does the equivalent of typing in this at the command line:
"_-layer" <space/enter> "on" <space/enter> "p-*" <space/enter> <space/enter>
Hopefully that makes some sense. ![]()
(if ("mysolution"=answer) then (click "Accept As Solution"))
--------------------------------------------------
Brandon Gingerich
Re: Replacing LISP with Macros for AutoCAD LT
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
2 kudos for that!
CSHADEDESIGN|AUTOCAD LT|LT-KB|DYNAMIC BLOCKS
Please mark Accept as Solution if your question is answered. Kudos gladly accepted. ⇘



