Block seperation using WBlock routine

Block seperation using WBlock routine

oosterop
Contributor Contributor
406 Views
4 Replies
Message 1 of 5

Block seperation using WBlock routine

oosterop
Contributor
Contributor

Hi,

 

I am looking for a routine that can make individual DWGs of all existing blocks in one drawing.

What I mean: we have a drawing with around 1000 blocks in it, which we want to store in separate DWGs

 

Thanks in advance.

 

Kr Erwin

0 Likes
Accepted solutions (1)
407 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

It's really like 2 sec of googling.

HERE or THIS 

0 Likes
Message 3 of 5

ronjonp
Mentor
Mentor
Accepted solution

Here's my simple offering:

(defun c:exportblocks (/ p)
  (setvar 'cmdecho 0)
  (setq p (strcat (getvar 'dwgprefix) "_ExportedBlocks\\"))
  (vl-mkdir p)
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(= 0 (vlax-get b 'isxref) (vlax-get b 'islayout))
      (command "._-wblock" (strcat p (vla-get-name b) ".dwg") (vla-get-name b))
    )
  )
  (setvar 'cmdecho 1)
  (alert p)
  (princ)
)
0 Likes
Message 4 of 5

oosterop
Contributor
Contributor

Thanks for your message, @ronjonp ! I've tested it and it works perfectly. Apologies for this very delayed response, I've been out of action for a while, hence the delay.

 

If I may delve a bit deeper into my question and your solution.

 

We're dealing with a lot of embedded blocks, and manually going through everything is impossible for this quantity. Could you modify the routine so that it creates a separate folder named after the embedded block, and then separates the underlying block within it? After or during the process of going through the first list of blocks (your initial routine).

 

Many thanks in advance.

 

Kr Erwin

0 Likes
Message 5 of 5

ronjonp
Mentor
Mentor

@oosterop 

Post a sample file.

0 Likes