Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with a macro

6 REPLIES 6
Reply
Message 1 of 7
msarqui
442 Views, 6 Replies

Help with a macro

Hi

 

I made this simple macro to do a Revcloud in layer 0, color 30.

 

^C^C_layer;thaw;0 ;_layer;on;0 ;_clayer;0;_cecolor;30;_revcloud;a;7;7;s;c;pause ;_cecolor;0 ;

 

I have two problems:

1. At the end, the color does not return to 0

2. Is that a way to save the active clayer and cecolor and return its values at the end?

 

Thanks!

6 REPLIES 6
Message 2 of 7
Kent1Cooper
in reply to: msarqui


@msarqui wrote:

.... 

I made this simple macro to do a Revcloud in layer 0, color 30.

 

^C^C_layer;thaw;0 ;_layer;on;0 ;_clayer;0;_cecolor;30;_revcloud;a;7;7;s;c;pause ;_cecolor;0 ;

 

I have two problems:

1. At the end, the color does not return to 0

2. Is that a way to save the active clayer and cecolor and return its values at the end?

....


The word pause is good in AutoLISP (command) functions, but not in macros -- a backslash \ is used for User input.  Also, you can do more than one Layer option in one Layer command, and Setting a Layer current by way of the command rather than the System Variable will turn it on if it's off.  And, I wonder whether you really want CECOLOR set to 0 [that's ByBlock], or more likely 256 [ByLayer].  And you probably don't want that space between the 0 and ; at the end, but also you don't need to use ; at the end to register the last entry -- Enter will be fed in unless the final entry is some control character.  In the case of resetting the prior Layer, you can use the LAYERP command.

 

I'm at my old-version station where I don't have some of those options in Revcloud, so there may need to be no ; or maybe another ; after the \ or something, but I'm going to give it a try:

 

^C^C_.-layer;_thaw;0;_set;0;;_.cecolor;30;_.revcloud;_a;7;7;_s;_c;\;_.cecolor;256;_.layerp

 

If you want to reset CECOLOR to whatever it was, not necessarily a fixed value, you would need to save its value and restore it, using some embedded AutoLISP:

 

^C^C(setq cec (getvar 'cecolor))_.-layer;_thaw;0;_set;0;;_.cecolor;30;_.revcloud;_a;7;7;_s;_c;\;(setvar 'cecolor cec)_.layerp

 

or the resetting of CECOLOR should be doable without AutoLISP, using the exclamation-point invoker of the variable:

 

^C^C(setq cec (getvar 'cecolor))_.-layer;_thaw;0;_set;0;;_.cecolor;30;_.revcloud;_a;7;7;_s;_c;\;_.cecolor !cec;_.layerp

 

EDIT:  Another way to handle the color is to not fiddle with the CECOLOR System Variable, but change the color of the Revcloud after it's drawn:

 

^C^C_.-layer;_thaw;0;_set;0;;_.revcloud;_a;7;7;_s;_c;\;_.chprop;_l;;_c;30;;_.layerp

Kent Cooper, AIA
Message 3 of 7
Anonymous
in reply to: msarqui

Add the following to your macro:

 

^C^C(setq curcolor (getvar "COLOR"))(setq curlayer (getvar "CLAYER"));_layer;thaw;0 ;_layer;on;0 ;_clayer;0;_cecolor;30;_revcloud;a;7;7;s;c;pause ;_cecolor;0 ;(setvar "COLOR" curcolor);(setvar "CLAYER" curlayer);

 

You are basically saving the current settings for Current Layer and Current Color before you start your macro and then reset these system variables at the end of your macro

 

Message 4 of 7
msarqui
in reply to: Anonymous

Thanks for the answers.

 

So far I tested everything and I think the problem is at the pause because when I use:

pause = Revcloud works but do not reset settings

\ = Revcloud does not work but do reset settings

\\ = Alow to draw one arc of Revcloud and do not reset settings

 

I tried also one \ with espace after, one \ without ; etc... and nothing works.

Message 5 of 7
Kent1Cooper
in reply to: msarqui


@msarqui wrote:

... when I use:

pause = Revcloud works but do not reset settings

\ = Revcloud does not work but do reset settings

\\ = Alow to draw one arc of Revcloud and do not reset settings

 

I tried also one \ with espace after, one \ without ; etc... and nothing works.


Since I don't have those options [I can try later at a different location with a newer version], I can't say, but if you do the Revcloud thing manually and keep careful track of every step you take, you should be able to make it work.  For every element of User input other than Enter/space [e.g. object selection or point pick], put in a backslash, and for every Enter/space, put in a semicolon or space, including after the last backslash if any are needed to complete the command.

Kent Cooper, AIA
Message 6 of 7
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

... (setq curcolor (getvar "COLOR")) ... (setvar "COLOR" curcolor) ... 


[There's a COLOR command that's like using CECOLOR as a command, except that COLOR brings up a dialog box for color selection rather than asking for a typed-in value as CECOLOR does.  But the System Variable name is CECOLOR, with the CE standing for Current Entity.]

Kent Cooper, AIA
Message 7 of 7
msarqui
in reply to: Kent1Cooper

Well well,

 

I found the solution here:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Can-a-script-allow-for-user-input/m-p...

 

Kent said :

 

I don't think the usual check on the CMDACTIVE System Variable, that people use to pause for User input until a command is finished, works in a Script -- at least, I haven't been able to get it to.  But you could have a Script call up a Lisp routine, similar to the one here:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/pause-for-user-input-in-a-lisp/m-p/86...

 

So, I made a simple Revcloud routine and I call it by sript. It works!

 

Thank you all for trying.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost