Clean-up drawing

Clean-up drawing

thebeesnees
Enthusiast Enthusiast
4,320 Views
12 Replies
Message 1 of 13

Clean-up drawing

thebeesnees
Enthusiast
Enthusiast

I'm looking to create a simple one-click drawing cleanup routine (macro/lisp) that includes all the actions below.

 

 

1. Select all blocks and explode (including nested blocks) - I use QSELECT for this and have to perform multiple times to explode any nested blocks.

 

2. Delete all wipeouts - I use QSELECT to perform this function

 

3. Select all items, place on Layer 0 and change all properties to BYBLOCK - I use CHPROP command

 

4. Delete all duplicate/overlapping objects - I use OVERKILL command

 

5. Fix any drawing errors - I use AUDIT command

 

6. Zoom extents and save drawing

 

 

I have managed to solve items 3-6 but have no idea how to convert QSELECT functions into macro format. My macro so far is:

 

^C^C_CHPROP;ALL;;LA;0;C;BYBLOCK;LT;BYBLOCK;LW;BYBLOCK;T;0;;-OVERKILL;ALL;;O;0.000001;I;N;P;D;N;B;Y;Y;T;Y;E;Y;A;Y;D;-PURGE;A;*;N;AUDIT;Y;ZOOM;E;

 

Any help would be appreciated.

0 Likes
Accepted solutions (1)
4,321 Views
12 Replies
Replies (12)
Message 2 of 13

TheCADnoob
Mentor
Mentor
0 Likes
Message 3 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

It makes for a long macro, but some AutoLisp functions can be used in them.  This should [minimally tested in a macro] Explode all Blocks in the current space, and all nested Blocks coming from them, etc., until there are no Insert objects left to Explode:

 

(while (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab))))) (initcommandversion) (command "_.explode" ss ""))

 

Are XREF's a possibility?  They would also be seen by that selection, but Exploding is not applicable.

Kent Cooper, AIA
Message 4 of 13

thebeesnees
Enthusiast
Enthusiast

Thanks, although not really sure how SSX command is useful in this instance?

0 Likes
Message 5 of 13

cadffm
Consultant
Consultant

Not?

You want to create selections by objecttype or objectproperties,

ssx is the only command (commandline-only) you can do that.

 

But pure Lisp is better in your case, see Kents answer.

Sebastian

0 Likes
Message 6 of 13

thebeesnees
Enthusiast
Enthusiast

I simply want to select all blocks, including nested blocks, and explode them - how do I achieve this using SSX?

0 Likes
Message 7 of 13

cadpro78
Advocate
Advocate

Why do you want to explode a block?  Some blocks can be exploding but if you have multiple times that block is used in the drawing, you can't just edit to correct all of them at once. 

 

0 Likes
Message 8 of 13

thebeesnees
Enthusiast
Enthusiast

The whole point of cleaning a file is to remove as much unnecessary information as possible thus block definitions, layers, etc are not required and need to be purged.

 

Once cleaned the file will be inserted into a master file, becoming a block, usually acting as an underlay for our own drawing work. There is no intention to manipulate these files thus block definitions no longer serve a purpose.

 

 

Message 9 of 13

Kent1Cooper
Consultant
Consultant

@thebeesnees wrote:

The whole point of cleaning a file is to remove as much unnecessary information as possible thus block definitions ... are not required and need to be purged.

.... block definitions no longer serve a purpose.


They do still serve a purpose, in memory savings.  One of the primary reasons for Blocks is that the information about all the pieces inside them is stored only once, in the Block definition, and Insertions of them need only insertion point, scale factors, rotation and Layer, but don't need to hold information about all the details of all the pieces within them at ever insertion.  When you Explode the Blocks, all those separate pieces that were in all those Block insertions now have all their information [Layers, locations of endpoints and centers and vertices and so on, radii, text content, etc., etc.] all stored in the drawing file separately and independently and unnecessarily repeatedly.  If Blocks are complex and/or there are a lot of them, that will significantly bloat the file size.

Kent Cooper, AIA
0 Likes
Message 10 of 13

thebeesnees
Enthusiast
Enthusiast

I agree in principle however in this instance I am trying keep our own drawing file as clean as possible.

We don't want all the layers, objects, block definitions from an imported drawing cluttering our files hence "cleaning" them first. The cleaned file is inserted is a block and just acts as a discrete underlay, usually placed on a grey layer.

0 Likes
Message 11 of 13

thebeesnees
Enthusiast
Enthusiast

I've added your routine to the beginning of my macro which now looks like this...

 

^C^C(while (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'ctab))))) (initcommandversion) (command "_.explode" ss ""));^C^C(if (setq ss (ssget "_X" '((0 . "WIPEOUT")(410 . "Model"))))
(command "_.erase" ss "")
);^C^C_CHPROP;ALL;;LA;0;C;BYBLOCK;LT;BYBLOCK;LW;BYBLOCK;T;0;;-OVERKILL;ALL;;O;0.000001;I;N;P;D;N;B;Y;Y;T;Y;E;Y;A;Y;D;-PURGE;A;*;N;AUDIT;Y;ZOOM;E;

 

I'm sure there are more elegant ways of achieving same results but works well enough. Thanks for help

 

0 Likes
Message 12 of 13

Kent1Cooper
Consultant
Consultant

@thebeesnees wrote:

... I am trying keep our own drawing file as clean as possible. We don't want all the layers, objects, block definitions from an imported drawing cluttering our files hence "cleaning" them first. ..


There are plenty of routines around that will [for example] force everything in all Block definitions to Layer 0 and color ByLayer and so on, so you can get Layering "cleaned" without the memory waste of Exploding all Blocks.  In my opinion, a drawing is "cleaner" if exactly repeated content is contained in Block insertions instead of existing separately in all locations.

Kent Cooper, AIA
Message 13 of 13

thebeesnees
Enthusiast
Enthusiast

Firstly, thanks for the feedback. Much appreciated.

 

The only contention I have, which may be based on my misunderstanding what affects drawing performance most, is that often blocks contained within drawings provided can be extremely inefficient. They are usually flattened exports from non-Autodesk 3D modelling software. This usually means large amounts of duplicated/overlapping objects which clearly impairs performance (anecdotally this appears to be the case).

 

Simply cleaning/optimising the drawing improves performance significantly and allows us to control the appearance better. Already getting positive feedback after implementing procedure in the office.

 

Again, thanks for the help.

 

 

0 Likes