Jump to content

change color of all objects inside the blocks


Dayananda

Recommended Posts

(setq pt1 (getpoint))
(setq pt2 (getpoint))

(setq xss2 (ssget"C" pt1 pt2  '((0 . "INSERT") )))

(if xss2
 (repeat (setq i (sslength xss2))
   (setq obj (tblobjname "BLOCK" (cdr (assoc 2 (entget (ssname xss2 (setq i (1- i))))))))
   (while (setq obj (entnext obj))
     (and (= (cdr (assoc 0 (setq get (entget obj)))) "CIRCLE")
          (print (cdr (assoc 40 get))))
     )
   )
 )

I need to modify the above code to change the color all entities inside the blocks to red.

Please do not use visual lisp codes .

Link to comment
Share on other sites

Try this

 

(defun c:test ( / xss2 i obj ent lst)
(setq xss2 (ssget '((0 . "INSERT") )))

(if xss2
  (repeat (setq i (sslength xss2))
    (setq obj (tblobjname "BLOCK" (cdr (assoc 2 (entget (setq ent (ssname xss2 (setq i (1- i)))))))))
    (while (setq obj (entnext obj))
      (setq lst (entget obj))
      (if (cdr (assoc 62 lst)) (entmod (subst (cons 62 1) (assoc 62 lst) lst)) (entmod (append lst '((62 . 1)))))
    )
    (entupd ent)
  )
)
)

I'll leave the integration up to you

 

You do know you are changing the block DEFINITION here?

Edited by dlanorh
  • Like 1
Link to comment
Share on other sites

@dlanorh

AFAIK you don't need to check for code 62. The append will work since it's the last thing read in the list. On the flip side I've seen items with truecolor /colorbook set (420/430 codes) and subst 62 does nothing.

 

Link to comment
Share on other sites

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