Author Topic: [XDrX-PlugIn(153)] Select the entity to set a random color (color number 1-255)  (Read 121 times)

0 Members and 2 Guests are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 504
https://www.cadtutor.net/forum/topic/74275-assigning-random-colors-to-each-linepolyline-within-a-selection-set/

Code: [Select]
(defun c:xdtb_entrandclr (/ ss clr)
  (xdrx-begin)
  (if (setq ss (xdrx-ssget
(xdrx-string-multilanguage
   "\n选择实体<退出>:"
   "\nSelect Entity<Exit>:"
)
       )
      )
    (progn
      (mapcar '(lambda (x)
(setq clr (xdrx-math-rand 1 255))
(xdrx-setpropertyvalue x "color" clr)
       )
      (xdrx-ss->ents ss)
      )
    )
  )
  (xdrx-end)
  (princ)
)
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net