Author Topic: Display number color of objects  (Read 3673 times)

0 Members and 1 Guest are viewing this topic.

vnanhvu

  • Guest
Display number color of objects
« on: August 17, 2011, 12:23:14 AM »
Anyone know how to display number color of objects without to Layer properti Manager? Ex.: I have layer 1 ( color bylayer set: red ( 1 ), i know color number of layer 1 without open Layer properties manager.
Thanks for all !

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Display number color of objects
« Reply #1 on: August 17, 2011, 01:00:11 AM »
Code: [Select]
(cdr (assoc 62 (tblsearch "LAYER" <LayerName>)))
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

vnanhvu

  • Guest
Re: Display number color of objects
« Reply #2 on: August 17, 2011, 01:43:13 AM »
Can you help me with your code become complete command. Because  the knowledge that my limited and  sorry about messing with this.
Thanks again

kruuger

  • Swamp Rat
  • Posts: 637
Re: Display number color of objects
« Reply #3 on: August 17, 2011, 02:07:06 AM »
?
Code: [Select]
(defun c:CL (/ OB)
  (if (setq OB (entsel "\nSelect object: "))
    (princ
      (strcat
        "\nNumber color of object is: "
        (itoa
          (cdr
            (assoc 62
              (tblsearch "LAYER"
                (cdr (assoc 8 (entget (car OB))))
              )
            )
          )
        )
      )
    )
    (princ "\n** Nothing selected **")
  )
  (princ)
)
maybe also CTRL+1 or QPMODE  :wink:
k.
« Last Edit: August 17, 2011, 02:10:41 AM by kruuger »

vnanhvu

  • Guest
Re: Display number color of objects
« Reply #4 on: August 17, 2011, 03:47:37 AM »
Thank you very much. Would be perfect if you could display on green, not  under command.
Thanks again !

kruuger

  • Swamp Rat
  • Posts: 637
Re: Display number color of objects
« Reply #5 on: August 17, 2011, 04:03:03 AM »
Thank you very much. Would be perfect if you could display on green, not  under command.
Thanks again !
what display on green ?
k.

vnanhvu

  • Guest
Re: Display number color of objects
« Reply #6 on: August 17, 2011, 04:08:54 AM »
Sorry no  " green " --->>" screen "  :-P Dísplay same my pic upload

kruuger

  • Swamp Rat
  • Posts: 637
Re: Display number color of objects
« Reply #7 on: August 17, 2011, 04:44:41 AM »
Sorry no  " green " --->>" screen "  :-P Dísplay same my pic upload
Code: [Select]
(defun c:CL (/ OB)
  (if (setq OB (entsel "\nSelect object: "))
    (alert ;;; replace with princ
      (strcat
....
?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Display number color of objects
« Reply #8 on: August 17, 2011, 08:12:36 AM »
You can use this routine.
http://www.lee-mac.com/dinfo.html
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

vnanhvu

  • Guest
Re: Display number color of objects
« Reply #9 on: August 17, 2011, 11:42:07 AM »
With Lee's Lisp display color object " bylayer", no display " color bylayer "  :oops: I hope you develope kruuger's lisp that can display dialog color ( this only display color number on command line )

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Display number color of objects
« Reply #10 on: August 17, 2011, 11:56:11 AM »
Code: [Select]
(defun c:TEst (/ _color ent data)

  (defun _color (n)
    (if (numberp n)
      (cond ((cdr (assoc n
                         '((0 . "ByBlock")
                           (1 . "Red")
                           (2 . "Yellow")
                           (3 . "Green")
                           (4 . "Cyan")
                           (5 . "Blue")
                           (6 . "Magenta")
                           (7 . "White")
                           (256 . "ByLayer")
                          )
                  )
             )
            )
            ((itoa n))
      )
    )
  )

  (if (setq ent (car (entsel "\nSelect object to display layer's color: ")))
    (alert (strcat "Object Layer: "
                   (cdr (assoc 8 (setq data (entget ent))))
                   "\nLayer color: "
                   (_color (cdr (assoc 62 (tblsearch "LAYER" (cdr (assoc 8 data))))))
                   "\nObject color: "
                   (cond ((_color (cdr (assoc 62 data))))
                         ("ByLayer")
                   )
           )
    )
  )
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Display number color of objects
« Reply #11 on: August 17, 2011, 12:11:28 PM »
In Lee's routine replace with this sub-function.
Code: [Select]
  ;;  CAB version
  (defun _GetColour ( e / c )   
    (if (setq c (cdr (assoc 62 e)))     
      (cond
        (
          (cdr
            (assoc c
             '(
                (0 . "ByBlock")
                (1 . "Red")
                (2 . "Yellow")
                (3 . "Green")
                (4 . "Cyan")
                (5 . "Blue")
                (6 . "Magenta")
                (7 . "White")
              )
            )
          )
        )
        ( (itoa c) )
      )
      (strcat "ByLayer -> " (itoa (cdr (assoc 62 (tblsearch "LAYER" (cdr (assoc 8 e))))))) ;;  CAB change
    )
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

vnanhvu

  • Guest
Re: Display number color of objects
« Reply #12 on: August 17, 2011, 12:24:38 PM »
Thank Alanjt, Cab and Kruuger very much. Wished everyone happy  :police:

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Display number color of objects
« Reply #13 on: August 17, 2011, 12:36:14 PM »
Or even going a bit further:
Code: [Select]
;;  CAB/Irné version
(defun _GetColour (e / _GetColorName c)
  (defun _GetColorName (c) ;Irné change
    (cond
      (
       (cdr
         (assoc c
                '(
                  (0 . "ByBlock")
                  (1 . "Red")
                  (2 . "Yellow")
                  (3 . "Green")
                  (4 . "Cyan")
                  (5 . "Blue")
                  (6 . "Magenta")
                  (7 . "White")
                 )
         )
       )
      )
      ((itoa c))
    )
  )
  (if (setq c (cdr (assoc 62 e)))
    (_GetColorName c)
    (strcat "ByLayer -> " (_GetColorName (cdr (assoc 62 (tblsearch "LAYER" (cdr (assoc 8 e)))))))
    ;;  CAB change
  )
)
Now it displays "Bylayer -> Green" instead of "Bylayer -> 4"  :whistle:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12917
  • London, England
Re: Display number color of objects
« Reply #14 on: August 17, 2011, 12:37:15 PM »
Cheers guys, I'll consider these changes for the next version  :-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Display number color of objects
« Reply #15 on: August 17, 2011, 12:40:18 PM »
Or even a smaller change:
Code: [Select]
;;  CAB/Recursive version
(defun _GetColour (e / c)
  (if (setq c (cdr (assoc 62 e)))
    (cond
      (
       (cdr
         (assoc c
                '(
                  (0 . "ByBlock")
                  (1 . "Red")
                  (2 . "Yellow")
                  (3 . "Green")
                  (4 . "Cyan")
                  (5 . "Blue")
                  (6 . "Magenta")
                  (7 . "White")
                 )
         )
       )
      )
      ((itoa c))
    )
    (strcat "ByLayer -> " (_GetColour (tblsearch "LAYER" (cdr (assoc 8 e))))) ;Irné change to recursive
    ;;  CAB change
  )
)
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.