Jump to content
samifox

set local color to object inside a nested block (without entering to block mode)

Recommended Posts

hi

 

i need to be able to changh the color of object that live inside a block (sometimes nasted blocks) without entering the block.

 

for example, i have a window block, it comes with blue as the color, i want that window to have a local color of 11, i want to do that with no need to enter the block, as said sometimes the window is nasted inside the block/

 

how can it be done?

 

THanks

Shay

Share this post


Link to post
Share on other sites
(defun tst1 ( / ent col)
   (and 
     (setq ent (car (nentsel "\nSelect entity to change color")))
     (setq col (acad_colordlg 0))
     (setq ent (vlax-ename->vla-object ent))
     (vlax-property-available-p ent 'color T)
     (progn (vla-put-color ent col) T)
     (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)
 )
)

(defun tst2 ( / sel ent col)
 (and 
   (setq sel (nentsel "\nSelect entity to change color"))
   (cond ((or (= 2 (length sel)) (= 1 (length (last sel))))(setq ent (car sel)))
          (T (setq ent (car (last sel)))))
   (setq col (acad_colordlg 0))
   (setq ent (vlax-ename->vla-object ent))
   (vlax-property-available-p ent 'color T)
   (progn (vla-put-color ent col) T)
   (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)
 )
)

Share this post


Link to post
Share on other sites
opps...it wont effect my f**** block

 

attached

 

thanks

Shay

 

 

think tst1 can change the color (of a single entity) and was hoping (tst2) would do it for the entire (nested) block but sadly... also , because its a nested block , update 1 means update all. Will try to have a look later cause somebody used the W-word against me (work)

Share this post


Link to post
Share on other sites
i consider marry you :)

 

 

Yeah I look dashing on my photo hey!

 

 

maybe a little improvement (but restrictions of a nested block remain , see for example master Lee's NestedMove program) :

(defun tst3 ( / ent col done inp ent ss i p2)
 (vl-load-com)
 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)) done nil col (acad_colordlg 0))
 (if col
   (progn
     (prompt "\nEsc, enter, Rmouse to cancel, zoom with E(extend), Z(oom) or + / -\nSelect ")
     (while (not done)
(setq inp (vl-catch-all-apply 'grread (list nil 4 2)))
(if (vl-catch-all-error-p inp)
  (progn (setq done t) (prompt "\nDone."))
  (cond
    ; if point selected
    ((= (car inp) 3)
     (setq ent (nentselp (cadr inp)))
     ; if point has object under it
     (if ent
       (_uec (car ent) col)
       (progn
  (if (and (setq i 0 p2 (getcorner (cadr inp) "\tOther corner : "))
    (setq ss (ssget "c" (cadr inp) p2)))
    (while (setq ent (ssname ss i)) (_uec ent col) (setq i (1+ i)))
  )
       )
     )
    ); end (= (car inp) 3)
    ; user pressed E of e
    ((member inp '((2 69)(2 101))) (command "zoom" "e"))
    ; user clicked R-mouse button, pressed enter or space (done selecting)
    ((or (equal (car inp) 25)(member inp '((2 13)(2 32))))
     (setq done t))
    ; user pressed +
    ((equal inp '(2 43)) (command "zoom" "2x"))
    ; user pressed -
    ((equal inp '(2 45)) (command "zoom" ".5x"))
    ; user pressed z or Z
    ((member inp '((2 122)(2 90))) (command "'zoom" ""))
         ); end cond
       ); end if
     ); end while
   ); end progn
 ); end if col
)

Share this post


Link to post
Share on other sites

Here's another:

(defun c:foo (/ c d e)
 ;; RJP » 2018-08-09
 (cond	((setq c (acad_truecolordlg 1))
 (setq d (vla-get-activedocument (vlax-get-acad-object)))
 (while	(setq e (car (nentsel "\nSelect entity to change color: ")))
   (entmod (append (entget e) c))
   (vla-regen d acactiveviewport)
 )
)
 )
 (princ)
)

Share this post


Link to post
Share on other sites
Here's another:

(defun c:foo (/ c d e)
 ;; RJP » 2018-08-09
 (cond	((setq c (acad_truecolordlg 1))
 (setq d (vla-get-activedocument (vlax-get-acad-object)))
 (while	(setq e (car (nentsel "\nSelect entity to change color: ")))
   (entmod (append (entget e) c))
   (vla-regen d acactiveviewport)
 )
)
 )
 (princ)
)

 

 

cleaner and shorter... but no way I'm gonna marry you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×