jim78b
Guest
I would like to make a script that clicking on a block totally changes the color independent from the layer... can you do it? ? ?
Why not use the properties set to dablocco (byblock)?I would like to make a script that clicking on a block totally changes the color independent from the layer... can you do it? ? ?
;;;cambia il colore ai blocchi nidificati
(defun c:ccb (/ cmd b_name col list_b en ed )
;*** gp 02/12/2011 ***
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_undo" "_begin")
(setq b_name (cdr (assoc 2 (entget (car (entsel "\nselezionare il blocco "))))))
(setq col (getstring "\nnumero colore: "))
(setq list_b (cons b_name list_b))
(setq b_def (tblsearch "block" b_name))
(setq en (cdr (assoc -2 b_def)))
(while en
(setq ed (entget en))
(if (= (cdr (assoc 0 ed)) "insert")
(progn
(setq b_name (cdr (assoc 2 ed)))
(setq list_b (cons b_name list_b))
)
)
(setq en (entnext en))
)
(repeat (setq n (length list_b))
(setq b_name (nth (setq n (1- n)) list_b))
(command "-bedit" b_name "_chprop" "_all" "" "c" col "" "_bclose" "")
)
(setvar "cmdecho" cmd)
(command "_undo" "_end")
(princ)
)
Good morning to all, I would like to ask for information about this lisp, I tried it on some blocks and it works correctly, but some blocks that contain attributes, those remain of the original color, you can change it so that even the color of the attributes changes?I have updated the lisp of the other discussion, which, of course, changing the color to nested blocks the change is also reflected to all the others that contain them.
Code:;;;cambia il colore ai blocchi nidificati (defun c:ccb (/ cmd b_name col list_b en ed ) ;*** gp 02/12/2011 *** (setq cmd (getvar "cmdecho")) (setvar "cmdecho" 0) (command "_undo" "_begin") (setq b_name (cdr (assoc 2 (entget (car (entsel "\nselezionare il blocco ")))))) (setq col (getstring "\nnumero colore: ")) (setq list_b (cons b_name list_b)) (setq b_def (tblsearch "block" b_name)) (setq en (cdr (assoc -2 b_def))) (while en (setq ed (entget en)) (if (= (cdr (assoc 0 ed)) "insert") (progn (setq b_name (cdr (assoc 2 ed))) (setq list_b (cons b_name list_b)) ) ) (setq en (entnext en)) ) (repeat (setq n (length list_b)) (setq b_name (nth (setq n (1- n)) list_b)) (command "-bedit" b_name "_chprop" "_all" "" "c" col "" "_bclose" "") ) (setvar "cmdecho" cmd) (command "_undo" "_end") (princ) )
thank you so much for the help, and instead why does this block not change the color according to you? ?Actually, the attributes change color, but you have to sync them. you just type the attsync or sincatt command and will magically appear the color. without typing the command I allow me to add the synchronization line to the lisp of the good gp.
(defun c:ccb (/ cmd b_name col list_b en e )
_
(setq cmd (getvar "cmdecho")
(setvar "cmdecho" 0)
(command "_undo" "_begin")
(setq b_name (cdr (assoc 2 (entget (car) (entsel "\nsel select the block: ")))))
(setq col (getstring "\nnumero colore: ")
(setq list_b (cons b_name list_b))
(setq b_def (tblsearch "block" b_name))
(setq en (cdr -2 b_def)))
(sing)
(setq and (entget en)
(if (= (cdr) "insert")
(progn)
(setq b_name (cdr (assoc 2 ed))))
(setq list_b (cons b_name list_b))
)
)
(setq en (entnext en)
)
(repeat (setq n (length list_b))
(setq b_name (nth (setq n (1-n)) list_b))
(command "-bedit" b_name "_chprop" "_all"" "c" with ""_bclose "")
)
(vl-cmdf "_attsync" "n" b_name)
(setvar "cmdecho" cmd)
(command "_undo" "_end")
(princ)
)
hi, I ask one last thing, can you enter the command for synchronization of the attribute this lisp?all you can reduce in:
(defun c:ccb2 (/ blocks block color)
(vl-load-com)
(setq blocks (vla-get-blocks (vla-get-activedocument))
block (vlax-ename->vla-object (car (entsel "\nselect reference block: ")
color (getint "\nscegliere colore: "
)
(vlax-map-collection)
(vla-item blocks (vla-get-name block)
'(lambda (elem)
(vla-put-color elem color)
)
)
(vl-cmdf "_regen")
)