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

Command line layer color change turns layer on

11 REPLIES 11
Reply
Message 1 of 12
david_rock
2083 Views, 11 Replies

Command line layer color change turns layer on

Hello,

 

I've noticed that when I cnage the colour of all larers via the command line any layers which are off are switched to on.

 

This is quite anoying, it mans I have to first save the layer state, change the layer colours then restore the layer state.

 

Has it always been like this or only in AutoCAD 2015? Is there a variable I can change to prevent it from happening?

 

For Example:

 

First turn off a layer. Then run this lisp:

(command "-layer" "c" "8" "*" "")

 

You will notice the layer you turned off has now turned on.

 

Kind Regards

David

 

Tags (3)
11 REPLIES 11
Message 2 of 12
doni49
in reply to: david_rock

I was just able to confirm this behavior in 2012.

 

I can't tell you how often (if at all) it's been reported to them. But if nobody reports it (such as assuming that someone else already has), then they'll never know about it -- and the more people who DO report it, the more chance it'll get fixed.

 

I'd suggest submitting this as a bug report at the following link.  And if you're on subscription, open a support ticket and report it that way as well (YES I'm saying submit it twice).


http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1109794



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 3 of 12
Volker_C
in reply to: david_rock

I've confirmed that this is a problem going back to at least AutoCAD 2009. I'm not sure how far back the functionality changed but I don't see any previous reports so I'll go ahead and notify the product team about this issue. Thanks for letting us know.

 

Cheers,

Volker

Please let us know if your questions have been answered by selecting, "Accept as Solution"


Volker C.
SR Technical Support Specialist, KDE
Autodesk Customer Council | Only One AutoCAD | AutoCAD Blog

Message 4 of 12
miroko
in reply to: Volker_C

Hi

 

I know this is a bit old post but seems without solution.

 

I still have same problem on AutoCAD 2015.

Is there any update on this issue?

 

regards

miroko

Message 5 of 12
doni49
in reply to: miroko

Miroko: you and the OP are both using 2015. So I would expect you to have the same issue. Unless a bug is something major (one example might changing a line's color causes the line to be deleted), I wouldn't expect to see it fixed in any less than 3 versions. That's about the life cycle that I've seen.

And that's not to say that it WILL be fixed in 2018 just that I would not expect to see it any sooner.
Don Ireland
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 6 of 12
Kent1Cooper
in reply to: Volker_C


@Volker_C wrote:

I've confirmed that this is a problem going back to at least AutoCAD 2009. ....


It's also true at least as far back as the 2004 version.  But it makes sense:  the Layer's color number is negative when it's turned off -- here with Layer 0 in the default color 7, but turned off:

 

Command: (tblsearch "layer" "0")
((0 . "LAYER") (2 . "0") (70 . 0) (62 . -7) (6 . "Continuous"))

 

So if you give it a positive number, that will turn it on.

 

Try this [minimally tested]:

 

(defun C:LC8 (/ layinfo col); = Layers all Color 8 [not turning On those that are Off]
  (while (setq layinfo (tblnext "layer" (not layinfo))); step through Layers
    (setq col (cdr (assoc 62 layinfo))); current color number [positive or negative]
    (command "_.layer" "_color" (* (/ col (abs col)) 8) (cdr (assoc 2 layinfo)) "")
      ; assign color 8 if on, -8 if off -- calculation returns 1 or -1
  ); while
  (princ)
); defun
Kent Cooper, AIA
Message 7 of 12
miroko
in reply to: Kent1Cooper

Kent1Cooper,

 

Thank you for the lisp.

It is working fine.

 

Unfortunatelly it is not working in AutoCAD LT for an obvious reason 🙂

But at least problem in 'FULL' is possible to solve as I see.

 

Is it possible to modify the lisp so that it is not all layers but only the ones with some defined wildcard like:

*|*

?

 

 

 

 

I LT I tried making script including saving layers state and then change color and then invoke back layers state but then also color is turned back... It is possible to select that color is not set back in the layer states but unfortunatelly this option is as 'toggle', cannot say that it shall be ON or OFF, so next time it is used it will be toggled again. So for LT seems no solution.

Here is the script by the way which I tried:

 

beginning_of_script

-layer
a
s
xrefgrey


c
8
*|*

-layer
a
r
xrefgrey


-layer
a
d
xrefgrey

 

 

 

end_of_script

 

 

 

regards

miroko

 

 

 

In meantime I also wrote ticket on subscription to AutoDesk, will write here answer when is concluded.

 

 

Message 8 of 12
Kent1Cooper
in reply to: miroko


@miroko wrote:

.... 

Is it possible to modify the lisp so that it is not all layers but only the ones with some defined wildcard like:

*|*

?

....


Yes, that's an easy modification:

 

(defun C:LXC8 (/ layinfo col); = Layers all Xref-dependent Color 8 [not turning On those that are Off]
  (while (setq layinfo (tblnext "layer" (not layinfo))); step through Layers
    (if (wcmatch (cdr (assoc 2 layinfo)) "*|*"); it's an Xref-dependent Layer
      (progn
        (setq col (cdr (assoc 62 layinfo))); current color number [positive or negative]
        (command "_.layer" "_color" (* (/ col (abs col)) 8) (cdr (assoc 2 layinfo)) "")
          ; assign color 8 if on, -8 if off -- calculation returns 1 or -1
      ); progn
    ); if
  ); while
  (princ)
); defun

 

 

[That assumes, of course, that you haven't used "|" in other Layer names.  But the method can also be used with other characters or strings of characters.]

Kent Cooper, AIA
Message 9 of 12
dbroad
in reply to: miroko

@miroko:

 

I concur with Kent that this is not a bug.  It is as designed behavior and goes back, as far as I know, to the very first version.  On/off is implemented as the sign of the color.  There are other convenient ways to change the color without changing the on/off status, just not by script.  The layer dialog allows you to select all the layers and change their colors without changing their on/off status.

 

At least on the full version of AutoCAD, I don't think I would want the behavior of the -layer command to change.

 

There are a couple of newer features that accomplish some of the intent of graying out the xref layers: 

1) Using XDWGFADECTL if the need is to make the xrefs appear on screen to be background.

2) Use plotstyles to adjust all xref layers to plot screened.

 

For those using full featured autocad, a script is possible using activex without much fuss because the ActiveX color property is not related to the layeron property.

 

;;grey out xrefs
;;NOTE.  The permanency of these changes depends on the visretain variable.
(defun c:greyxreflays ( / lay)  ;D. C. Broad, Jr. 8/10/2016
  (vlax-for lay	(vla-get-layers
		  (vla-get-activedocument (vlax-get-acad-object))
		)
    (if	(wcmatch (vla-get-name lay) "*|*")
      (vla-put-color lay 8)
    )
  )
  (princ)
)

 

 

Architect, Registered NC, VA, SC, & GA.
Message 10 of 12
miroko
in reply to: dbroad

@Kent1Cooper

 

Your lisp is working. But if we have many layers to be changed then it takes quite a time...

I noticed that it runs through all the layers separatelly in a loop untill nothing more is to be done by function.

And yes, it is about xref layers.

 

@dbroad

Your lisp is working as well, and is very fast. I guess is slightly different approach.

Only one need to regen in the end since result is not visible.

I implemented the regen into your lisp and now is working fine.

Could you just confirm that I placed regen in correct place (end of lisp and as part of the whole command)?

 

;;grey out xrefs
;;NOTE.  The permanency of these changes depends on the visretain variable.
(defun c:greyxreflays ( / lay)  ;D. C. Broad, Jr. 8/10/2016
  (vlax-for lay (vla-get-layers
    (vla-get-activedocument (vlax-get-acad-object))
  )
    (if (wcmatch (vla-get-name lay) "*|*")
      (vla-put-color lay 😎
    )
  )
  (princ)
(command "regen")
)

 

@Kent1Cooper @dbroad

I got answer from AutoDesk on ticket and they confirmed that it is normal behaviour (although may sound unlogic since in 'dialog box' for layers it is possible to change color without layers being turned 'on').

So it will not be reported as bug, but they also said that they will ask other expert to confirm that it is as-designed.

 

Here is answer from AutoDesk:

 

quote

Turned off layer are fully calculated by AutoCAD - freezed layers not.

You can check this by turning off layers with objects - type move - select objects by typing "all" and move. You will see that also the invisible objects have been moved. That does not happen with object on freezed layers, because those are not calculated, once they are freezed. 

So, in your case you want all layers (selected by "*") to change their color. ALL calculated Layers change their color. In order to accomplish that, AutoCAD has to turn on all Layers.  If you want to prevent this, please use "Freeze" to make Layers invisible.

unquoted

 

 

miroko

 

Message 11 of 12
dbroad
in reply to: miroko

@miroko

 

Thanks for the feedback.  It did not require a regen for me but I believe you.  Behavior might be system variable or hardware dependent.  To avoid using command methods and their possible negative aspects, try this instead:

;;grey out xref layers, permanency depends on visretain=1
(defun c:greyxreflays ( / doc) ;;D. C. Broad, Jr. 8/11/2016
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vlax-for lay	(vla-get-layers doc)
		  
    (if	(wcmatch (vla-get-name lay) "*|*")
      (vla-put-color lay 8)
    )
  )
  (vla-regen doc acAllViewports)
  (princ)
)
Architect, Registered NC, VA, SC, & GA.
Message 12 of 12
miroko
in reply to: dbroad

thanks for all the help

 

🙂

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

Post to forums  

Autodesk Design & Make Report

”Boost