AutoCAD 2010/2011/2012

Reply
Contributor
Oliver_C87
Posts: 18
Registered: ‎04-27-2012
Message 1 of 15 (1,968 Views)
Accepted Solution

LAYER SHORTCUT

1968 Views, 14 Replies
04-30-2012 01:29 AM

Hi All

 

s it possible to create shortcuts to change between layers rather than using the pull down menu to select the layer required??

 

Any assistance on this or creating custom shortcuts would be greatly appreciated.

 

Thanks

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 2 of 15 (1,964 Views)

Re: LAYER SHORTCUT

04-30-2012 01:46 AM in reply to: Oliver_C87

Hi,

 

you can use a little bit of LISP to do that. Look at this lines:

(defun C:L1()(command "_-LAYER" "_M" "MyLayer1" ""))

(defun C:L2()(command "_-LAYER" "_M" "MyLayer2" ""))

(defun C:L3()(command "_-LAYER" "_M" "MyLayer3" ""))

(defun C:L4()(command "_-LAYER" "_M" "MyLayer4" ""))

 

If you copy these lines at the end of your ACADDOC.LSP you have 4 additional commands (L1 or L2 or L3 or L4 like the green colored letters) that makes layers (layername = orange part) active, and if they don't exist they are created.

 

So if you start then the command L1 it makes the layer "MyLayer1" active.

 

You can now copy or modify these lines (they are just samples to let you understand what's happening), create your own commands (each line one command) and give each command a layer you like.

 

HTH, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
Oliver_C87
Posts: 18
Registered: ‎04-27-2012
Message 3 of 15 (1,961 Views)

Re: LAYER SHORTCUT

04-30-2012 01:54 AM in reply to: Alfred.NESWADBA

Thanks for responding Alfred.

 

Do I have to use 'L1' as the command? or can i simply type 1 (as a number) rather than 'L' all the time?

 

Thanks again.

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 4 of 15 (1,958 Views)

Re: LAYER SHORTCUT

04-30-2012 02:00 AM in reply to: Oliver_C87

Hi,

 

>> Do I have to use 'L1' as the command?

If you defined the command to be named "L1" then you  have to type "L1<ENTER>" to start the command.

If you want a command to be named with just one character you can do that, e.g.;

(defun C:1()(command "_-LAYER" "_M" "MyLayer1" ""))

Now you can start it with 1<ENTER>, but be careful with numbers as command names, it's not that it's forbidden, but I have not a good feeling then. (just a feeling, not more).

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
Oliver_C87
Posts: 18
Registered: ‎04-27-2012
Message 5 of 15 (1,955 Views)

Re: LAYER SHORTCUT

04-30-2012 02:05 AM in reply to: Alfred.NESWADBA

Excellent!

 

Are you concerned using numbers for commands might cause problems with the program/ script?

 

Also while we are on the topic, can you alter existing shortcut commands for example; co = copy can i modify it to c = copy?

 

Thanks again.

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 6 of 15 (1,953 Views)

Re: LAYER SHORTCUT

04-30-2012 02:11 AM in reply to: Oliver_C87

Hi,

 

>> Also while we are on the topic, can you alter existing shortcut commands

>> for example; co = copy can i modify it to c = copy?

That shortcuts are defined in the file ACAD.PGP. If you want them to be modified do that modification in this file (or when you have installed the ExpressTools, then you can use command ALIASEDIT to modify the content of this file).

 

>> Are you concerned using numbers for commands might cause problems with the program/ script?

Yes, anytime and anywhere, and exactly following >>>murphys laws<<< :smileywink:

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
Oliver_C87
Posts: 18
Registered: ‎04-27-2012
Message 7 of 15 (1,951 Views)

Re: LAYER SHORTCUT

04-30-2012 02:36 AM in reply to: Alfred.NESWADBA

Sorry Alfred, i'm not familair where the ACAD.PGP. file is located and Im not familiar with Express tools.

 

I am using a 2011 Lt verison. will Express tools work with this?

 

Thanks. You 've been very helpful

Contributor
Oliver_C87
Posts: 18
Registered: ‎04-27-2012
Message 8 of 15 (1,949 Views)

Re: LAYER SHORTCUT

04-30-2012 02:39 AM in reply to: Oliver_C87

Oh and I also forgot to ask where:

(defun C:L1()(command "_-LAYER" "_M" "MyLayer1" ""))

 

Is located?

 

Thanks

*Expert Elite*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 9 of 15 (1,947 Views)

Re: LAYER SHORTCUT

04-30-2012 02:47 AM in reply to: Oliver_C87

Hi,

 

>> I am using a 2011 Lt verison

Sorry to say now, but for LT all the above tips won't work as LT does not have LISP included. And so also ExpressTools don't exist in LT-version of AutoCAD.

 

At least the ACAD.PGP does exist and can be modified by using a normal texteditor like Notepad.The position of the file depends on your operating system, the easiest way is to search your local disk for a file named ACAD.PGP, it will find one in your user-directory (for release 2011), that can be modified.

IMPORTANT: before making any modifications ==> backup your file!

 

- alfred -

 

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
Oliver_C87
Posts: 18
Registered: ‎04-27-2012
Message 10 of 15 (1,942 Views)

Re: LAYER SHORTCUT

04-30-2012 03:17 AM in reply to: Alfred.NESWADBA

Thanks for help Alfred

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.