DuanJinHui Posted June 17, 2015 Share Posted June 17, 2015 I want change 3dsolid color(color not same) ,But too many 3Dsolid objects (>300) , SO, Can use lisp change 3DSolid color randomly ? (ACI) , It's possible ? Quote Link to comment Share on other sites More sharing options...
ReMark Posted June 17, 2015 Share Posted June 17, 2015 You want to randomly assign a color to 300+ solid objects? Will each object be assigned an unique color or are you going to use a limited range of colors? Quote Link to comment Share on other sites More sharing options...
DuanJinHui Posted June 17, 2015 Author Share Posted June 17, 2015 You want to randomly assign a color to 300+ solid objects? Will each object be assigned an unique color or are you going to use a limited range of colors? The color can be repeated . Quote Link to comment Share on other sites More sharing options...
ReMark Posted June 17, 2015 Share Posted June 17, 2015 Have you come up with a set of colors that would be to your liking? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2015 Share Posted June 17, 2015 Hi, Here is my attempt (defun c:test (/ ss i) ;;------------------------------------;; ;; Tharwat 17.06.2015 ;; ;; Color 3dSolid objects randomly ;; ;;------------------------------------;; (if c c (setq c 1)) (if (setq ss (ssget "_:L" '((0 . "3DSOLID")))) (repeat (setq i (sslength ss)) (entmod (append (entget (ssname ss (setq i (1- i)))) (list (cons 62 (rem c 255))) ) ) (setq c (+ c 3)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 17, 2015 Share Posted June 17, 2015 The following will assign a pseudo-random colour to each selected solid: ([color=BLUE]defun[/color] c:3dcol ( [color=BLUE]/[/color] i s ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"3DSOLID"[/color])))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]vla-put-color[/color] ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) (LM:randrange 1 255)) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; Rand - Lee Mac[/color] [color=GREEN];; PRNG implementing a linear congruential generator with[/color] [color=GREEN];; parameters derived from the book 'Numerical Recipes'[/color] ([color=BLUE]defun[/color] LM:rand ( [color=BLUE]/[/color] a c m ) ([color=BLUE]setq[/color] m 4294967296.0 a 1664525.0 c 1013904223.0 $xn ([color=BLUE]rem[/color] ([color=BLUE]+[/color] c ([color=BLUE]*[/color] a ([color=BLUE]cond[/color] ($xn) (([color=BLUE]getvar[/color] 'date))))) m) ) ([color=BLUE]/[/color] $xn m) ) [color=GREEN];; Random in Range - Lee Mac[/color] [color=GREEN];; Returns a pseudo-random integral number in a given range (inclusive)[/color] ([color=BLUE]defun[/color] LM:randrange ( a b ) ([color=BLUE]fix[/color] ([color=BLUE]+[/color] a ([color=BLUE]*[/color] (LM:rand) ([color=BLUE]-[/color] b a -1)))) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) The above random number functions are from my site here. Quote Link to comment Share on other sites More sharing options...
DuanJinHui Posted June 18, 2015 Author Share Posted June 18, 2015 Hi, Here is my attempt Thank you very much . Tharwat The following will assign a pseudo-random colour to each selected solid: Thank you very much . Lee Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 18, 2015 Share Posted June 18, 2015 Thank you very much . Tharwat You are very welcome. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 18, 2015 Share Posted June 18, 2015 No problem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.