Jump to content

Recommended Posts

Posted

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 ?

 

2015-06-17.jpg

Posted

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?

Posted
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 .

Posted

Have you come up with a set of colors that would be to your liking?

Posted

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)
 )

Posted

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.

Posted
Hi,

 

Here is my attempt :)

 

 

Thank you very much . Tharwat :thumbsup:

 

The following will assign a pseudo-random colour to each selected solid:

 

Thank you very much . Lee :thumbsup:

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...