Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 36

Thread: Change layer colour macro

  1. #11
    AUGI Addict
    Join Date
    2005-07
    Posts
    2,356
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Quote Originally Posted by Avatart View Post
    In the bit of macros where it defines the Layer state name, just put this in:
    Code:
     
    (setq statename (getvar "Date"))
    Then when you are going to delete it use the code:
    Code:
     
    !statename
    You have to make sure that your TEXTEVAL is set to 1, or it won't see "!statename" as a Lisp variable.
    Like this?

    Code:
     ^c^c-layer;a;s; (setq statename (getvar "Date"));c   c;7;*;a;r; !statename;d; !statename;;;
    TEXTEVAL is set to 0 by default (on my comp anyway), would it cause any problems to have it set to 1 permanantly? Or would it be better to include setting it to 1 and back to 0 in the macro (if it's even possible) ?

  2. #12
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Quote Originally Posted by Steve.Sanderson(UK) View Post
    Like this?

    Code:
     ^c^c-layer;a;s; (setq statename (getvar "Date"));c   c;7;*;a;r; !statename;d; !statename;;;
    TEXTEVAL is set to 0 by default (on my comp anyway), would it cause any problems to have it set to 1 permanantly? Or would it be better to include setting it to 1 and back to 0 in the macro (if it's even possible) ?
    It is probably better programming to test for the value of TEXTEVAL, then force it to "1", then reset it to what you tested for. Like this:
    Code:
     
    (setq textevalval (getvar "Texteval"))
    blah blah blah
    (setvar "Texteval" textevalval)
    (setq textevalval nil)
    I set the variable back to nil as this is good practice, you should always clear your variables after you have finished with them. I didn't need to preceed the "textevalval" with an exclamation, as it is inside brackets and therefore being treated as raw Lisp.

    You can certainly set TEXTEVAL to "1" permanently, I have it set that way and have no adverse effects. The only thing that can go wrong is if you need to enter some text that starts with a "!".

  3. #13
    AUGI Addict
    Join Date
    2005-07
    Posts
    2,356
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Quote Originally Posted by Avatart View Post
    It is probably better programming to test for the value of TEXTEVAL, then force it to "1", then reset it to what you tested for.
    I set the variable back to nil as this is good practice, you should always clear your variables after you have finished with them. I didn't need to preceed the "textevalval" with an exclamation, as it is inside brackets and therefore being treated as raw Lisp.

    You can certainly set TEXTEVAL to "1" permanently, I have it set that way and have no adverse effects. The only thing that can go wrong is if you need to enter some text that starts with a "!".
    That makes sense, although starting to go over my head a little

    The timestamp version of the macro won't work, I think it contains too many characters for a macro. So as a simple macro hopefully the temp layer state version should be good enough for the OP.

  4. #14
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Quote Originally Posted by Steve.Sanderson(UK) View Post
    That makes sense, although starting to go over my head a little

    The timestamp version of the macro won't work, I think it contains too many characters for a macro. So as a simple macro hopefully the temp layer state version should be good enough for the OP.
    You can have LOADS of characters in a macro, what went wrong was that you had some extra spaces that AutoCad treats as carriage returns, working code is:
    Code:
     
    ^c^c-layer;a;s;(setq statename (getvar "Date"));c   c;7;*;a;r;!statename;d;!statename;;;

  5. #15
    AUGI Addict
    Join Date
    2005-07
    Posts
    2,356
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Quote Originally Posted by Avatart View Post
    You can have LOADS of characters in a macro, what went wrong was that you had some extra spaces that AutoCad treats as carriage returns, working code is:
    Code:
     
    ^c^c-layer;a;s;(setq statename (getvar "Date"));c   c;7;*;a;r;!statename;d;!statename;;;
    Okay that works.

    Thought there was a limited number of characters, but obviously not. I should stop meddling with things I don't understand

  6. #16
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    928
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Quote Originally Posted by Steve.Sanderson(UK) View Post
    Okay that works.

    Thought there was a limited number of characters, but obviously not. I should stop meddling with things I don't understand
    It was meddling with things that I didn't understand that let me understand them.

  7. #17
    Member
    Join Date
    2007-09
    Location
    Macclesfield Cheshire, England.
    Posts
    46
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Hi,

    Avatart, Steve, thanks for all your help on this. I read your listings and have just been trying to make it work. I had to add a couple of returns ( in the macro after the first 'c' to make it work:

    ^C^C-layer;a;s;temp;c;;;c;7;*;a;r;temp;d;temp;;;

    However, there is still one issue. The first 'c' in the string TOGGLES the colour state from a No to a Yes, or vice versa. So, if the state is the wrong setting when you run the macro, it doesn't work. Further, as bad luck should have it, the layer state configuration (when listed mid command) seems to be the same for all open drawings. So using the macro in one drawing means it cannot be used in another because the layer state (yes/no) setting is the wrong way round.

    One way around this may be to use deisel to change the layer state setting before running the command. Unfortunately, I don't know the variable that stores these settings - do you?

    Many thanks for all you help.

    Regards

    Maurice.

  8. #18
    AUGI Addict
    Join Date
    2005-07
    Posts
    2,356
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Hi Maurice,

    I did notice the toggling of the colour to on/off, but if you assign the macro to a tool button, then you just need to click on it and if the toggle was the wrong way round then just click on it to run the macro again and it will then work, if that makes sense.

    I can't think of another way around it at the moment (which means nothing )

  9. #19
    Member
    Join Date
    2007-09
    Location
    Macclesfield Cheshire, England.
    Posts
    46
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Hi,
    (Something weird has happened, I posted this reply about an hour ago, and its not there. I must have done something wrong, but here it is again.)

    Avatart, Steve, thanks for help. I have read your listings and tried them out. I had to add a couple of returns in the macro to make it work:

    ^c^c-layer;a;s;temp;c;;;c;7;*;a;r;temp;d;temp;;;

    However, there is still one outstanding issue. The first 'c' in the string TOGGLES the property restore state (listed during the command) from Yes to No, or vice versa. So, if the state happens to be the wrong way round when the macro is issued, it doesn't work. Further, as bad luck should have it, the property restore states are the same for all open drawing. So if the macro is issued in one drawing it fails in another open drawing.

    The only way I can think may overcome this is to use a deisel routine to set the restore states before the rest of the macro. Unfortunately, I don't know the variable that stores these restore states - do you?

    Many thanks for your help on this.

    Regards

    Maurice.

  10. #20
    Member
    Join Date
    2007-09
    Location
    Macclesfield Cheshire, England.
    Posts
    46
    Login to Give a bone
    0

    Default Re: Change layer colour macro

    Hi Steve,
    I take your point, but the macro loses its usefulness then. ( it has to be quicker than going into the layer manager and doing it manually) If you don't know which way round it is then you would have to look at the layers to see whether it had worked before running it again. Also, what happens if the on/off state is the wrong way round - you loose all the on/off layer setting and you wouldn't know how to put them back.

    Still, it good fun trying.

    Maurice.

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Change all Objects of one colour to another colour
    By tburke in forum AutoCAD General
    Replies: 15
    Last Post: 2016-03-04, 01:53 PM
  2. Replies: 4
    Last Post: 2012-08-15, 04:59 PM
  3. change layer colour
    By sight025025875459 in forum AutoLISP
    Replies: 3
    Last Post: 2011-05-20, 07:32 AM
  4. Can't change the colour of mpolygon
    By nikkojara291504 in forum AutoCAD Map 3D - General
    Replies: 11
    Last Post: 2011-03-03, 06:55 PM
  5. Change colour of all entities within a block
    By rajarshi in forum AutoLISP
    Replies: 3
    Last Post: 2005-10-17, 05:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •