Author Topic: Entity Block Color Change to true color  (Read 3282 times)

0 Members and 1 Guest are viewing this topic.

reyas1123

  • Newt
  • Posts: 50
Entity Block Color Change to true color
« on: September 20, 2016, 08:59:46 AM »
Hi,
I found a lisp file ENCC-BLCC.lsp  the lisp can change only index normal color, my query is there a way to include to change entity to  true color in this Lisp? likewise if possible to include crossing or window in selecting entity in the block.

Thanks.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #1 on: September 20, 2016, 09:13:44 AM »
Look into the acad_truecolordlg function. It will return a 420 number than can be applied to objects. Or you can go to Lee's site and study THIS.
« Last Edit: September 20, 2016, 09:21:47 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

reyas1123

  • Newt
  • Posts: 50
Re: Entity Block Color Change to true color
« Reply #2 on: September 20, 2016, 09:25:58 AM »
Thanks Ron for the reply, how i wish to do so but honestly I am a newbie to LSP  Thanks.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #3 on: September 20, 2016, 10:39:21 AM »
Thanks Ron for the reply, how i wish to do so but honestly I am a newbie to LSP  Thanks.
Give this a try .. did not test much so use with caution.
« Last Edit: September 20, 2016, 01:47:41 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

reyas1123

  • Newt
  • Posts: 50
Re: Entity Block Color Change to true color
« Reply #4 on: September 21, 2016, 02:12:01 AM »
Thanks Ron it works perfectly,

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Entity Block Color Change to true color
« Reply #5 on: September 21, 2016, 07:25:30 AM »
Nice routine guys. Sure beats going through the layer manager on this... Great job.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #6 on: September 21, 2016, 08:51:19 AM »
Thanks Ron it works perfectly,
Glad to help.  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #7 on: September 21, 2016, 08:56:00 AM »
Nice routine guys. Sure beats going through the layer manager on this... Great job.
Be aware that the routine posted by the OP sets the color byobject not bylayer.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Entity Block Color Change to true color
« Reply #8 on: September 21, 2016, 09:01:14 AM »
I did not notice that. Thanks Ron for pointing that out.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #9 on: September 21, 2016, 09:22:41 AM »
I did not notice that. Thanks Ron for pointing that out.
Here's a quick one to change the layer color:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:cc (/ _color c e l)
  2.   (defun _color (ename color / code el i l)
  3.     ;; Get truecolor number from acad_truecolordlg if it exists
  4.     (setq code (last color))
  5.     ;; Strip old truecolor value
  6.     (if (assoc 420 (entget ename))
  7.       (entmod (vl-remove 'nil
  8.                          (mapcar '(lambda (x)
  9.                                     (cond ((= (car x) 62) '(62 . 256))
  10.                                           ((= (car x) 420) nil)
  11.                                           (x)
  12.                                     )
  13.                                   )
  14.                                  (entget ename)
  15.                          )
  16.               )
  17.       )
  18.     )
  19.     (setq el (entget ename))
  20.     ;; Apply new color
  21.     (if (setq i (assoc (car code) el))
  22.       (entmod (subst code i el))
  23.       (entmod (append el (list code)))
  24.     )
  25.   )
  26.   (if (setq c (acad_truecolordlg
  27.                 (atoi (if (getenv "RJP_CC")
  28.                         (getenv "RJP_CC")
  29.                         "1"
  30.                       )
  31.                 )
  32.               )
  33.       )
  34.     (while (setq e (nentsel "\nPick an item to change its layer color: "))
  35.       (if (setq l (tblobjname "layer" (cdr (assoc 8 (entget (car e))))))
  36.         (progn (_color l c) (setenv "RJP_CC" (itoa (cdar c))))
  37.       )
  38.     )
  39.   )
  40.   (princ)
  41. )
« Last Edit: September 21, 2016, 09:26:09 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Entity Block Color Change to true color
« Reply #10 on: September 21, 2016, 09:27:24 AM »
Now, that's cool.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #11 on: September 21, 2016, 11:02:09 AM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Entity Block Color Change to true color
« Reply #12 on: September 21, 2016, 12:47:25 PM »
I think it could actually be reduced to:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:cc ( / c e )
  2.     (and (setq c (acad_truecolordlg (cond ((last cc-default)) (1)) nil))
  3.          (setq cc-default c)
  4.          (while (setq e (car (nentsel "\nSelect object to change layer colour: ")))
  5.              (entmod (append (entget (tblobjname "layer" (cdr (assoc 8 (entget e))))) c))
  6.          )
  7.     )
  8.     (princ)
  9. )

Nice one Ron  :-)

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Entity Block Color Change to true color
« Reply #13 on: September 21, 2016, 12:50:11 PM »
Lee, how do you take 40 lines of code down to 10?? lol! I can actually understand that more. lol. Great job.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Entity Block Color Change to true color
« Reply #14 on: September 21, 2016, 01:25:48 PM »
I think it could actually be reduced to:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:cc ( / c e )
  2.     (and (setq c (acad_truecolordlg (cond ((last cc-default)) (1)) nil))
  3.          (setq cc-default c)
  4.          (while (setq e (car (nentsel "\nSelect object to change layer colour: ")))
  5.              (entmod (append (entget (tblobjname "layer" (cdr (assoc 8 (entget e))))) c))
  6.          )
  7.     )
  8.     (princ)
  9. )

Nice one Ron  :)
Thanks :)
I guess I should have tested against the layers. When applying an index color to an object that already had a true color assigned, it would not update.
Sometimes I wish I had 1/2 of your brain  8)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC