• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

lisp colri random

  • Thread starter Thread starter rotten80
  • Start date Start date

rotten80

Guest
Good day to all!
I'm looking for a pious soul that can help me, and I ask my question here.
I have a series of polylinese closed with a text in the center, all in the same layer.

I would have the need to change color to the polylines and its text contained with a random color and let them remain in the same layer.
the result should be like:
poly1+text1--->color rgb random 1------->layer contours
poly2+testo2--->color rgb random 2------->layer contours
poly3+testo3--->color rgb random 3--------->layer contours
poly4+testo4--->color rgb random 4--------->layer contours


if you have a lisp solution or there is already a similar command in cad you know I would be grateful
greetings
steak
 
any second internal text is not treated, the boundary layer must already exist.
Code:
(defun c:xx ( / selpoly n poly t_poly col)
    (if (and
            (princ "\nselezionare le polilinee")
            (setq selpoly (ssget '((0 . "lwpolyline") (-4 . "&=") (70 . 1))))
        )
        (repeat (setq n (sslength selpoly))
            (setq poly (ssname selpoly (setq n (1- n))))
            (setq t_poly
                     (ssget "_wp"
                            (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget poly)))
                            '((0 . "text,mtext"))
                     )
            )
            (setq col (lm:randrange 1 255))
            (setpropertyvalue poly "color" col)
            (vla-put-layer (vlax-ename->vla-object poly) "contorni")
            (if t_poly
                (progn
                    (setpropertyvalue (ssname t_poly 0) "color" col)
                    (vla-put-layer (vlax-ename->vla-object (ssname t_poly 0)) "contorni")
                )
            )
        )
    )
    (princ)
)
(defun lm:rand ( / a c m )
    (setq m   4294967296.0
          a   1664525.0
          c   1013904223.0
          $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
    )
    (/ $xn m)
)
(defun lm:randrange ( a b )
    (fix (+ a (* (lm:rand) (- b a -1))))
)
 
Mittico!!! works very well even if you skip some texts.... but apparently for my purpose it is better this way!
(I believe because they are placed in the center of the figure and therefore in some cases outside the polylinea)

thank you very much for your professionalism and competence
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

Back
Top