TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on July 26, 2019, 07:57:22 AM

Title: Filter By a Layer Color
Post by: MSTG007 on July 26, 2019, 07:57:22 AM
I am trying to figure out a way to select all the Color "8"'s in a drawing and then Change them to Color "47".

Just received new plotters and color 8 does not plot right for our pen styles in our department. (I know, we could change the CTB file but it is used company wide).

So to print, we need color 8 to be changed before we plot.

Any ideas? lol. Don't you love brain storming in the morning!

Thanks for your ideas.
Title: Re: Filter By a Layer Color
Post by: CAB on July 26, 2019, 08:01:24 AM
Some info here:
----------  Selection Sets  ----------------
http://www.theswamp.org/index.php?topic=1915.0  Select By Layer or Color
http://www.theswamp.org/index.php?topic=8451.0 SS Clipboard of sorts
http://www.theswamp.org/index.php?topic=8794.0
http://www.theswamp.org/index.php?topic=33979.msg393046#msg393046 determine which segment of the pline is selected
http://www.theswamp.org/index.php?topic=34793.msg400060#msg400060  gile
http://www.theswamp.org/index.php?topic=34793.msg400059#msg400059 Lee Mac
http://www.theswamp.org/index.php?topic=35028.0  alanJt
http://www.cadtutor.net/forum/showthread.php?72186&p=493190&viewfull=1#post493190 Lee Mac
Title: Re: Filter By a Layer Color
Post by: MSTG007 on July 26, 2019, 08:03:31 AM
thanks CAB,

I start looking into these.

Question is, I wonder if I should create a custom button that will execute the command before it plots.
Title: Re: Filter By a Layer Color
Post by: ChrisCarlson on July 26, 2019, 08:27:40 AM
You might want to use a network stored style file, update it once and everyone has the new version.

Also I do not know how your color 8 is setup but I would check to see what is causing the issue and look for a remedy rather than the band-aid. From a standards perspective it'll be a nightmare getting everyone to change their plotting style just for this issue.
Title: Re: Filter By a Layer Color
Post by: MSTG007 on July 26, 2019, 08:34:54 AM
My understanding is we no longer use a plotter "in a sense". Its a large format ink printer. So our Color 8 looks the same as our Color 9.
Title: Re: Filter By a Layer Color
Post by: ronjonp on July 26, 2019, 09:15:11 AM
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ d)
  2.   (vlax-for x (vla-get-layers d) (and (= 8 (vla-get-color x)) (vla-put-color x 47)))
  3.     (vlax-for b a (and (= 8 (vla-get-color b)) (vl-catch-all-apply 'vla-put-color (list b 47))))
  4.   )
  5.   (princ)
  6. )
Title: Re: Filter By a Layer Color
Post by: MSTG007 on July 26, 2019, 10:32:08 AM
Thank you Ron for this guide!
Title: Re: Filter By a Layer Color
Post by: Lee Mac on July 26, 2019, 12:19:11 PM
@Ron: Re this line:

Code - Auto/Visual Lisp: [Select]
  1. (vlax-for b a (and (= 8 (vla-get-color b)) (vl-catch-all-apply 'vla-put-color (list b 256))))

Changing an object's colour property from colour 8 to ByLayer could potentially alter the resulting display colour if the object resides on a layer whose layer colour is not colour 8 - I would advise that objects with an overridden colour property should have such property changed to the new colour (that is, unless you were to test whether the colour of the layer on which the object is assigned is equal to the colour override).
Title: Re: Filter By a Layer Color
Post by: ronjonp on July 26, 2019, 03:23:38 PM
@Ron: Re this line:

Code - Auto/Visual Lisp: [Select]
  1. (vlax-for b a (and (= 8 (vla-get-color b)) (vl-catch-all-apply 'vla-put-color (list b 256))))

Changing an object's colour property from colour 8 to ByLayer could potentially alter the resulting display colour if the object resides on a layer whose layer colour is not colour 8 - I would advise that objects with an overridden colour property should have such property changed to the new colour (that is, unless you were to test whether the colour of the layer on which the object is assigned is equal to the colour override).

Agreed .. that should have been setting the color to 47. Will update above *cheers*!
Title: Re: Filter By a Layer Color
Post by: BIGAL on August 01, 2019, 12:47:24 AM
Forget the code make a copy of your ctb edit it call it your plotter name, you can set pen 8 to any of the 256 colors, we had various ctb's depending on where it was being plotted. Just click on the color.