Author Topic: How to make Layer Control change color to ByLayer  (Read 284 times)

0 Members and 1 Guest are viewing this topic.

RGUS

  • Newt
  • Posts: 94
How to make Layer Control change color to ByLayer
« on: August 10, 2018, 04:03:37 AM »
With entities gripped in the drawing editor, how do I then select a layer from the Layer Control pulldown and change the entities to not only the Layer picked but the colour to ByLayer?

Will this require adding some lisp or reactor of some type?

It would have been great if the Layer Control changed to not only the Layer, but to the color and linetype of that layer.

Any help or suggestions are appreciated.

rkmcswain

  • Swamp Rat
  • Posts: 925
Re: How to make Layer Control change color to ByLayer
« Reply #1 on: August 10, 2018, 07:23:44 AM »
The color drop down does include the BYLAYER choice.
Also, what about using the SETBYLAYER command?

RGUS

  • Newt
  • Posts: 94
Re: How to make Layer Control change color to ByLayer
« Reply #2 on: August 10, 2018, 08:22:11 AM »
The color drop down does include the BYLAYER choice.
Also, what about using the SETBYLAYER command?

Yes, these do the job, but they form a two pick operation.
The 'Layer Control" dropdown changes the entity to the selected layer but in name only, it does not change the entity color or linetype to that of the selected layer as well.

I just wondered if there was a 'one pick' way of doing all three things without having to write my own "Layer change" command.

Thanks for your suggestions.

ronjonp

  • Needs a day job
  • Posts: 6764
Re: How to make Layer Control change color to ByLayer
« Reply #3 on: August 10, 2018, 08:39:40 AM »
CNTRL+A then CNTRL+1 and make the changes in the properties palette.

Windows 10 x64 - AutoCAD /C3D 2019

Custom Build PC

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9118
Re: How to make Layer Control change color to ByLayer
« Reply #4 on: August 10, 2018, 08:53:01 AM »
-ch
All
P
C
Bylayer
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

RGUS

  • Newt
  • Posts: 94
Re: How to make Layer Control change color to ByLayer
« Reply #5 on: August 10, 2018, 08:56:13 AM »
CNTRL+A then CNTRL+1 and make the changes in the properties palette.

Thanks, Ron, this also does the job but as a multiple keyboard pick operation.
I guess Autodesk only intended the Layer Control pulldown menu to change the layer name only.
Looks like a special purpose routine to change gripped entity to layer_name, color_bylayer and linetype_bylayer from a list of layers in the drawing will be required.
A one pick operation.

Thank you for your help.

RGUS

  • Newt
  • Posts: 94
Re: How to make Layer Control change color to ByLayer
« Reply #6 on: August 10, 2018, 09:02:41 AM »

ronjonp

  • Needs a day job
  • Posts: 6764
Re: How to make Layer Control change color to ByLayer
« Reply #7 on: August 10, 2018, 09:04:32 AM »
Here's something that will work within blocks too:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ a c d)
  2.  ;; RJP » 2018-08-10
  3.    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  4.  )
  5.    (if (= 0 (vlax-get b 'isxref))
  6.      (vlax-for o b (cond ((vlax-write-enabled-p o) (vla-put-color o 256))))
  7.    )
  8.  )
  9.  (foreach l a (vlax-put l 'lock -1))
  10.  (vla-regen d acallviewports)
  11.  (princ)
  12. )

Windows 10 x64 - AutoCAD /C3D 2019

Custom Build PC

rkmcswain

  • Swamp Rat
  • Posts: 925
Re: How to make Layer Control change color to ByLayer
« Reply #8 on: August 10, 2018, 09:05:26 AM »
Quote from: RGUS

I guess Autodesk only intended the Layer Control pulldown menu to change the layer name only.



Well, of course. Why would they make the LAYER control drop-down control, modify anything other than the LAYER?

RGUS

  • Newt
  • Posts: 94
Re: How to make Layer Control change color to ByLayer
« Reply #9 on: August 10, 2018, 09:18:15 AM »
Quote from: RGUS

I guess Autodesk only intended the Layer Control pulldown menu to change the layer name only.



Well, of course. Why would they make the LAYER control drop-down control, modify anything other than the LAYER?

LOL... so true... no sense in creating yet another "system variable" in case some punters also want to draw using color_bylayer and linetype.
I need to be more thankful to AutoDESK, I apologise for my query.

rkmcswain

  • Swamp Rat
  • Posts: 925
Re: How to make Layer Control change color to ByLayer
« Reply #10 on: August 10, 2018, 09:28:35 AM »
I guess I'm the one who is confused.

LAYER and COLOR are two separate properties.
It seems as if you expect that by changing the layer, AutoCAD should also set the COLOR property to BYLAYER?
Should it also set the linetype to bylayer? What about transparency and lineweight?




ronjonp

  • Needs a day job
  • Posts: 6764
Re: How to make Layer Control change color to ByLayer
« Reply #11 on: August 10, 2018, 09:29:37 AM »
Quote from: RGUS

I guess Autodesk only intended the Layer Control pulldown menu to change the layer name only.



Well, of course. Why would they make the LAYER control drop-down control, modify anything other than the LAYER?

LOL... so true... no sense in creating yet another "system variable" in case some punters also want to draw using color_bylayer and linetype.
I need to be more thankful to AutoDESK, I apologise for my query.
Set these two variable on startup and objects will default to be drawn linetype and color 'bylayer'.
Code: [Select]
(setvar 'celtype "bylayer")
(setvar 'cecolor "bylayer")
« Last Edit: August 10, 2018, 11:10:30 AM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2019

Custom Build PC

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9118
Re: How to make Layer Control change color to ByLayer
« Reply #12 on: August 10, 2018, 09:41:04 AM »
Here's something that will work within blocks too:
...

Here was something I wrote for ACAD 14--before vl--(doubt it worked within blocks though; and I don't remember autolisp enough to determine if it does) but it should work for all AutoCADs (windows or Mac).
Code - Auto/Visual Lisp: [Select]
  1. (defun colorByLayer (/ ss i elist)
  2.  (setq i -1)
  3.  (repeat
  4.    (sslength (setq ss (ssget "x" '((-4 . "/=") (62 . 256)))))
  5.     (entmod
  6.       (subst '(62 . 256) (assoc 62 (setq elist (entget (ssname ss (setq i (1+ i)))))) elist))
  7.  )
  8.  (princ)
  9. )
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--