TheSwamp

CAD Forums => CAD General => Topic started by: ELOQUINTET on February 11, 2004, 08:13:31 AM

Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 08:13:31 AM
i asked this question before but never really resolved it. i have some macros which create a layer set it current then perform a command. i would like to make it revert to the previous layer afterwards. the layer is a non plotting one and i keep forgetting to switch back. this would greatly help me if someone could throw me a bone. thanks

^C^C(command "-layer" "n" "VIEWPORT" "c" "WHITE" "VIEWPORT" "p" "n" "VIEWPORT" ) ;setvar clayer "VIEWPORT";MvEx_Ms2Ps;
Title: layer previous help
Post by: CADaver on February 11, 2004, 08:21:01 AM
Get the current layer first with (setq clay (getvar 'CLAYER"))

Then close with (setvar "clayer" clay)
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 08:30:10 AM
daron told me to write it this way before but i'm not getting any result.he also told me not to create a new layer called "o-hatch". If I want to make sure it exists, use make not new. I want to create it if it doesn't exist or just make it current if it does.
what's wrong with this?

(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" );(setq var (getvar 'clayer));setvar clayer "0-HATCH";hpname;STEEL;hpscale;1;hpang;0;bhatch;/;(setvar 'clayer var);

thanks for your help  :D
Title: layer previous help
Post by: CAB on February 11, 2004, 08:47:16 AM
Just a guess, parenthesis missing??

Code: [Select]
(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" );(setq var (getvar 'clayer));(setvar clayer "0-HATCH");hpname;STEEL;hpscale;1;hpang;0;bhatch;/;(setvar 'clayer var);
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 09:02:33 AM
nice try cab but no go.  :cry: just a thought wouldn't it make more sense to get the current layer at the beginning? if so would i do it like so?

(setq var (getvar 'clayer));(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" );(setvar clayer "0-HATCH");hpname;STEEL;hpscale;.0625;hpang;0;bhatch;/;(setvar 'clayer var);
Title: layer previous help
Post by: Mark on February 11, 2004, 09:05:34 AM
try using this
Code: [Select]
(getvar "clayer")
instead of this
Code: [Select]
(getvar 'clayer)
just a guess!
Title: layer previous help
Post by: CADaver on February 11, 2004, 09:14:25 AM
Quote from: eloquintet
(setq var (getvar 'clayer));(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" );(setvar clayer "0-HATCH");hpname;STEEL;hpscale;.0625;hpang;0;bhatch;/;(setvar 'clayer var);


That's how I'd do it, except I'd use double quotes around the variable name:
(setq var (getvar "clayer"))
and
(setvar "clayer" var)


Another suggestion, If you're going to make layer O-HATCH current anyway use "layer" "M" instead of "layer" "N".  "LAYER" "MAKE", makes the new layer current.

Code: [Select]
(setq var (getvar "clayer"));(command "-layer" "M" "0-HATCH" "c" "9" "0-HATCH" );hpname;STEEL;hpscale;.0625;hpang;0;bhatch;/;(setvar "clayer" var)
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 09:27:13 AM
here's the results i get. it looks to be halting at the transition between layer and hatch settings. how do i make this transition?

Command: (setq var (getvar "clayer"))
"0"
Command: (command "-layer" "M" "0-HATCH" "c" "9" "0-HATCH" )
-layer
Current layer:  "0"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
M
Enter name for new layer (becomes the current layer) <0>: 0-HATCH Enter an
option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
c
Enter color name or number (1-255): 9
Enter name list of layer(s) for color 9 <0-HATCH>: 0-HATCH Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
nil
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
hpname
Invalid option keyword.
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Title: layer previous help
Post by: daron on February 11, 2004, 09:45:10 AM
(http://honolulu.hawaii.edu/dinos/rex_skull_small.gif) Here's your bone. There is a toolbar near the layer pulldown, that has three white papers on it with a previous arrow. Hitting this button will set your previous layer state, including plottability. You can hit it as many times as you need to. Here's the toolbars code: ^C^C_LayerP
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 02:51:41 PM
sorry guys i was out for a bit. yes daron that's what i was thinking i could do initually just add;_layerp after my code but it didn't work. i really wish i could figure this out urrrrrrrrgh
Title: layer previous help
Post by: daron on February 11, 2004, 03:20:21 PM
On the command line, what happens when you run this:  (command "-layer" "M" "0-HATCH" "c" "9" "0-HATCH" ) ? I'll tell you what I get; an unfinished command. You can't automatically continue if you give control back to the user, which is what you've done. You need to add something to that. That is why you are getting this after:
Code: [Select]

nil
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
hpname
Invalid option keyword.
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 03:27:03 PM
ok that makes sense so what do i add to end the layer potion and start the hatch variable part?
Title: layer previous help
Post by: daron on February 11, 2004, 03:36:34 PM
In a lisp macro (command ...) all enter functions are dealt with using a set of double quotes, i.e. "". So, depending on how many you need to get out of the command, you'll need that many sets of quotes. In a menu you use semi-colons: ;. Understand?
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 03:45:48 PM
i'm not really following you. i'm new to this and am trying to decode what you guys show me. so are you saying i should be using : instead of " in here or no or just in the part before hpname. i'm lost  :oops:
Title: layer previous help
Post by: daron on February 11, 2004, 03:56:16 PM
It depends on your application. If you're writing the code directly in the menu, you program an enter function as a semi-colon ; not colon : . Now, if you are using a lisp macro; in the lisp file itself, you use empty quotes for enter "". Experiment with it a bit.
Title: layer previous help
Post by: ELOQUINTET on February 11, 2004, 04:53:09 PM
ok daron i've been experimenting and i got this which seems to work

(setq var (getvar "clayer"));(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" ) ;setvar clayer "0-HATCH";hpname;STEEL;hpscale;.0625;hpang;0;bhatch;\;_LayerP

i was trying to use make instead of new but it put the hatch on 0 layer which is the clayer not 0-hatch

thanks for all your wisdom  :wink:
Title: layer previous help
Post by: daron on February 11, 2004, 05:25:48 PM
(setq var (getvar "clayer"));(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" "") ;setvar clayer "0-HATCH";hpname;STEEL;hpscale;.0625;hpang;0;bhatch;\;_LayerP

Test that. See if it helps. As far as wisdom; I'm not testing my thoughts. I'm just throwing out ideas.
Title: layer previous help
Post by: ELOQUINTET on February 12, 2004, 08:00:26 AM
daron the last format i posted works so i'm just sticking with that thanks though
Title: layer previous help
Post by: CADaver on February 12, 2004, 09:39:43 AM
Just a clarification (if I can) about your comment pertaining to "" instead of ;

In your routine you're mixing LISP functions with menu commands.  And that's fine, a lot of folks do it that way.  I don't, cuz' I'm not smart enough to keep track of where I am.  I tend to use all one or the other.

In LISP, an ENTER in a command call is represented by dbl quotes ""
EX:  (command "-layer" "m" "peanutbutter" "")
That last "" closes the layer command

In menu syntax, the semi-colon represents an ENTER
EX: 'layer;m;peanutbutter;;
notice the two semi-colons at the end, one to enter the layer name PEANUTBUTTER and the last to close the layer command

Me being a keyboard junkie from way back, I tend to make lisp functions for everything.
Title: layer previous help
Post by: ELOQUINTET on February 12, 2004, 10:59:08 AM
understood thanks  :lol:
Title: layer previous help
Post by: ELOQUINTET on February 13, 2004, 01:05:27 PM
i have one more question about my button. everything is working but the selection in hatch. when i go to pick points it only allows me to select a single area and the dialog comes back up. how do i modify it for multiple selections? here's my button again:

(setq var (getvar "clayer"));(command "-layer" "n" "0-HATCH" "c" "9" "0-HATCH" ) ;setvar clayer "0-HATCH";hpname;STEEL;hpscale;.25;hpang;0;pickstyle;1;bhatch;\;_LayerP
Title: layer previous help
Post by: daron on February 13, 2004, 01:08:08 PM
Your best bet would be to write a lisp that would loop the pick point until you hit enter, then incorporate that command into the button.
Title: layer previous help
Post by: ELOQUINTET on February 13, 2004, 01:09:55 PM
hmmm i couldn't just put a pause in there? really need to learn lisp  :cry:
Title: layer previous help
Post by: daron on February 13, 2004, 01:20:35 PM
pause or \ only works once for each time you call it. The problem there is that you don't know how many times you'll call it. As far as learning lisp goes,
A) you should.
B) with (command "-layer" "n" ")-HATCH" "c" "9" "O-HATCH"), you're already some of the way there.
C) It's not that hard and it's fun
D) This particular road-block you're in would be perfect for any of us to help you learn.

If you'd like, start a different thread for this function and let's get you started. It won't take too long. Let's say you spend 30 minutes each day of, say your lunch time, and report in and test the things you're given. You do that and you'll be able to answer many of the questions you have on your own. Start the thread with the process in which you perform the actions you'd like simplified, then we'll show you how to find what you need and get you started writing it.