Jump to content

Keep color of block, explode it and give this color to its former elements


Ament

Recommended Posts

Hi everyone,

 

 

 

I've an issue and have no idea at all how to solve it this time. I even struggle to start with this one.

 

 

 

I've the following scenario: I have a block, let's say a table in a architectural layout. This table is placed several times in my drawing. In the block definition by default color is set to "By Block".

 

While placing it in my layout I define a color and instantiate the table (approx. 100 times). Later I have to do some changes. To be able to track the ones I changed I'll give another color to the moved tables.

 

Now I need to exchange my AutoCAD drawing with another software. Unfortunately this software is not familiar with blocks so that I have to explode them before I import it. I've a simple lisp for it.

 

So far so good. But of course, the color of the elements after exploding the block is not kept but changed back to "By Block" (Which does not exist anymore). What I need is a piece of code which capture the color of the block before exploding it and change the color of the elements former inside the exploded block to to this color.

 

 

 

I hope this makes sense to you. If not, please don't hesitate to ask and I'll try to make it clearer.

 

 

 

Best regards,

 

Ament

Link to comment
Share on other sites

:facepalm:Looks like I wasn't the only one with this issue. They made even a command themselves.

Just wonder why my google search didn't give me that option. Looks like I couldn't find the correct words. Thank you so much. That is exactly what I was looking for. :thumbsup:

Link to comment
Share on other sites

... The command looks quiet nice in interactive.. But I was struggeling to put it to my lisp. Found out that it is not a basic AutoCAD command and I can't run it in a lisp. Furthermore I found some hints how to do it manually, but actually I'm not that much into lisp that I was able to make it run :(

 

It would help me out a lot if I can get some small öisp which does it. Someone has the time to help me out?

Link to comment
Share on other sites

maybe something here for you :

 

 

http://www.cadtutor.net/forum/showthread.php?30901-Layer-Explode

 

 

or something like this

 

 

(defun c:test ( / blk col explodedObjects)
 (if (and (setq blk  (car (entsel)))
           (setq blk (vlax-ename->vla-object blk))
           (setq col (vla-get-color blk))
           (not (vl-catch-all-error-p
             (setq explodedObjects
               (vl-catch-all-apply 'vlax-invoke (list blk 'explode))))))
   (foreach obj explodedObjects (vla-put-Color obj col))
 )
)

 

 

or this

(defun c:t3 ( / blk col ll ur ss actDoc actSel)
 (vl-load-com) (setq actDoc (vla-get-activedocument (vlax-get-acad-object)))
 (if (and (setq blk  (car (entsel))) (setq blk (vlax-ename->vla-object blk))
   (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list blk 'll 'ur))))
   (mapcar 'set '(ll ur) (mapcar 'vlax-safearray->list (list ll ur))))
   (progn
     (setq col (vla-get-color blk))
     (vl-cmdf "_.explode" (vlax-vla-object->ename blk))
     (if (setq ss (ssget "w" ll ur))
(vlax-for obj (setq actSel (vla-get-activeselectionset actDoc)) (vla-put-Color obj col)))
   )
 )
)

 

 

btw , I changed test table to red , exploded it (manual) and all the objects stayed red.

 

 

 

 

If used on an attributed block , attributes will be exploded also. In that case have a look at Lee code here :

 

 

http://www.lee-mac.com/upgradedburst.html

 

 

Sure if you ask nicely he'll help you with the matter of color which should be a minor adjustment to his code

 

 

gr. Rlx

Edited by rlx
Link to comment
Share on other sites

  • 4 weeks later...

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