+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,246

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

    Registered forum members do not see this ad.

    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

  2. #2
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,106

    Default

    Code:
    (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)
      )
    )

  3. #3
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,246

    Default

    opps...it wont effect my f**** block

    attached

    thanks
    Shay
    Attached Files

  4. #4
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,106

    Default

    Quote Originally Posted by samifox View Post
    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)

  5. #5
    Super Member
    Using
    AutoCAD 2010
    Join Date
    Dec 2010
    Posts
    1,246

    Default

    i consider marry you

  6. #6
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,106

    Default

    Quote Originally Posted by samifox View Post
    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) :
    Code:
    (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
    )

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    949

    Default

    Here's another:
    Code:
    (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)
    )

  8. #8
    Senior Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2012
    Posts
    175

    Default

    Very nice, ronjonp.

  9. #9
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    949

    Default

    Quote Originally Posted by guran View Post
    Very nice, ronjonp.
    Thanks!

  10. #10
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,106

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by ronjonp View Post
    Here's another:
    Code:
    (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!

Similar Threads

  1. Lisp to change an entity layer in a nested block without entering block
    By Tripledot in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 27th Jul 2016, 12:39 pm
  2. Replies: 21
    Last Post: 28th Jan 2015, 02:11 pm
  3. Replies: 11
    Last Post: 16th Oct 2012, 03:33 pm
  4. Get block object from nested object
    By SteveK in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 26th Sep 2009, 03:21 pm
  5. Dynamic Block - changing object color
    By dvjstyles in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 5th Jan 2009, 02:11 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts