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.
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-*
Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
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.
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!
@Anonymous 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"))
------------------------------------------------------------------------------------
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.
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"))
------------------------------------------------------------------------------------
Do so please, I think that would be good for anyone who comes across this.
(Of course when you have the time that is. )
Regards, Charles Shade
CSHADEDESIGN | AUTOCAD LT | LT-KB | DYNAMIC BLOCKS
Please mark Accept as Solution if your question is answered. Kudos gladly accepted. ⇘
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"))
------------------------------------------------------------------------------------
2 kudos for that!
Regards, Charles Shade
CSHADEDESIGN | AUTOCAD LT | LT-KB | DYNAMIC BLOCKS
Please mark Accept as Solution if your question is answered. Kudos gladly accepted. ⇘
Thanks all for the help.
I have all my layer management LISP routines converted over to LT. Now on to the others!
This one is even better, a true toggle. The only thing is that you have to make sure the var "layon-off" (or whatever you're using) is created/existing with a value of 1 (specifies that said layers are on) before running it.
^C^C$M=$(if,$(=,$(getenv,layon-off),0),setenv;layon-off;1;_-Layer;ON;m*;;,setenv;layon-off;0;_-Layer;OFF;m*;;)^Z
HTH!
(if ("mysolution"=answer) then (click "Accept As Solution"))
------------------------------------------------------------------------------------
There are many on-off needs for AutoCAD users, these tips can be modified with a little imagination to do so much in LT.
I'm sure we all have our favorites, think about it during a typical day of CAD and the flood gates will open.
Remember though, SETENV accesses the Windows Registry to add these user "environment variables": some registry cleaners like to remove them. AFAIK limited Windows user accounts are not affected in creating them, but I've never tested it.
Are there any experts who would be able to create a macro tool that would change all layers in a drawing to one color?
Here is something I have started but I am new at this so maybe it would be less steps or some keywords I am not realizing...
^C^C_shiftselectalllayers;color;
if anyone knows that this would be possible or could tell me if Im wasting my time I would appreciate it!
Thanks for the cadvice!
Welcome to the Autodesk Forums!
You can open the Layer Command (LA), Shift select All the Layers as you would any group of files, Click on the Color for one of the layers and change to whatever Color to change all.
Can you do this by typing the various Commands at the Command line?
Something like LA, All, Color,...
If so this is what you need to create the Macro
Regards, Charles Shade
CSHADEDESIGN | AUTOCAD LT | LT-KB | DYNAMIC BLOCKS
Please mark Accept as Solution if your question is answered. Kudos gladly accepted. ⇘
Good Evening,
quick question at the end of the day. I have spent a half hour reading up on handles and understand each block or attributes have to to be automatically numbered by autocad.
My question:
is using the same block with the same handles(will not work if the block has different handles) in multiple drawings just fundamentally easier to modify through excel or notepad? Is this a great way to save fonts and text sizing within a block?
seems that it would be a better tool if the command could take the attributes and applythem to blocks of different shapes and sizes.
I just wanna see the broader picture.
Thanks for the support in earlier posts!
Dan
Can't find what you're looking for? Ask the community or share your knowledge.