Jump to content

Overkill all including blocks?


CADkitt

Recommended Posts

Is it possible to do an overkill true the whole drawing including the inside of blocks?

And the overkill now also kills the dynamic blocks :( I guess that would be a problem.

Link to comment
Share on other sites

  • 2 years later...

Dear All,

I can see CADkitt did a good question. I have this problem now with a drawing recovered from bak after cad crashed and I notice all lines within blocks are duplicated.

Has anybody had this problem solved? Maybe someone could try to write a lisp using OVERKILL inside all blocks, please. If it is impossible for it to deal with parametric blocks, let them stay untouched, omitting them somehow, but the rest of simple blocks (including nesting please) could be overkilled then. That would be one speed step forward in cleaning the file.

Link to comment
Share on other sites

Here is a very simple program to delete duplicate and zero-length lines entirely from the drawing:

 

[color=GREEN];; Line Kill  -  Lee Mac[/color]
[color=GREEN];; Removes duplicate or zero-length lines from the drawing and[/color]
[color=GREEN];; also from within blocks and nested blocks.[/color]

([color=BLUE]defun[/color] c:linekill ( [color=BLUE]/[/color] dup lck lst p1 p2 tol zln )
   
   ([color=BLUE]setq[/color] tol 1e-8  [color=GREEN];; Tolerance[/color]
         zln 0
         dup 0
   )
   ([color=BLUE]vlax-for[/color] lay ([color=BLUE]vla-get-layers[/color] (LM:acdoc))
       ([color=BLUE]if[/color] ([color=BLUE]=[/color] [color=BLUE]:vlax-true[/color] ([color=BLUE]vla-get-lock[/color] lay))
           ([color=BLUE]progn[/color]
               ([color=BLUE]setq[/color] lck ([color=BLUE]cons[/color] lay lck))
               ([color=BLUE]vla-put-lock[/color] lay [color=BLUE]:vlax-false[/color])
           )
       )
   )
   ([color=BLUE]vlax-for[/color] blk ([color=BLUE]vla-get-blocks[/color] (LM:acdoc))
       ([color=BLUE]if[/color] ([color=BLUE]=[/color] [color=BLUE]:vlax-false[/color] ([color=BLUE]vla-get-isxref[/color] blk))
           ([color=BLUE]vlax-for[/color] obj blk
               ([color=BLUE]cond[/color]
                   (   ([color=BLUE]/=[/color] [color=MAROON]"AcDbLine"[/color] ([color=BLUE]vla-get-objectname[/color] obj)))
                   (   ([color=BLUE]equal[/color] 0.0
                           ([color=BLUE]distance[/color]
                               ([color=BLUE]setq[/color] p1 ([color=BLUE]vlax-get[/color] obj 'startpoint))
                               ([color=BLUE]setq[/color] p2 ([color=BLUE]vlax-get[/color] obj 'endpoint))
                           )
                           tol
                       )
                       ([color=BLUE]setq[/color] zln ([color=BLUE]1+[/color] zln))
                       ([color=BLUE]vla-delete[/color] obj)
                   )
                   (   ([color=BLUE]vl-some[/color]
                           ([color=BLUE]function[/color]
                               ([color=BLUE]lambda[/color] ( x )
                                   ([color=BLUE]and[/color] ([color=BLUE]equal[/color] ([color=BLUE]car[/color] x) p1 tol) ([color=BLUE]equal[/color] ([color=BLUE]cadr[/color] x) p2 tol))
                               )
                           )
                           lst
                       )
                       ([color=BLUE]setq[/color] dup ([color=BLUE]1+[/color] dup))
                       ([color=BLUE]vla-delete[/color] obj)
                   )
                   (   ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]list[/color] p1 p2) lst)))
               )
           )
       )
       ([color=BLUE]setq[/color] lst [color=BLUE]nil[/color])
   )
   ([color=BLUE]foreach[/color] layer lck
       ([color=BLUE]vla-put-lock[/color] layer [color=BLUE]:vlax-true[/color])
   )
   ([color=BLUE]vla-regen[/color] (LM:acdoc) [color=BLUE]acallviewports[/color])
   ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 zln)
       ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\n"[/color] ([color=BLUE]itoa[/color] zln) [color=MAROON]" zero-length line"[/color] ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 zln) [color=MAROON]" removed."[/color] [color=MAROON]"s removed."[/color])))
       ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nNo zero-length lines found."[/color]))
   )
   ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 dup)
       ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\n"[/color] ([color=BLUE]itoa[/color] dup) [color=MAROON]" duplicate line"[/color] ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 dup) [color=MAROON]" removed."[/color] [color=MAROON]"s removed."[/color])))
       ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nNo duplicate lines found."[/color]))
   )
   ([color=BLUE]princ[/color])
)

[color=GREEN];; Active Document  -  Lee Mac[/color]
[color=GREEN];; Returns the VLA Active Document Object[/color]

([color=BLUE]defun[/color] LM:acdoc [color=BLUE]nil[/color]
   ([color=BLUE]eval[/color] ([color=BLUE]list[/color] '[color=BLUE]defun[/color] 'LM:acdoc '[color=BLUE]nil[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color]))))
   (LM:acdoc)
)
([color=BLUE]vl-load-com[/color])
([color=BLUE]princ[/color])

Link to comment
Share on other sites

Did you tried to access the block definition with BEDIT command and call next OVERKILL while inside block editor? Seems to work. For sure, this is feasible for a limited number of blocks.

 

Also, since the issues occurred after a crash, try to run the AUDIT command which may fix some errors.

Link to comment
Share on other sites

Thanks Guys! That ware quick responses :)

 

Lee Mac, thank you for the code! I'll try it and give you the feedback. But, before I do, please confirm how this routine deals with parameters inside dynamic blocks? Is it safe and keeps actions? And secondly, although I could read it from the first three lines of the code, will it go in deep with nested blocks? Well, I will test-drive it on a spare drawing.

 

MSasu, thank you too for interest. The drawing was recovered by recover command, and purged audited several times, unfortunately those commands don't deal with duplicates. I can do Overkill in a single block manually, but as you say, here I have to many blocks to proceed one by one, and they are nested.

Link to comment
Share on other sites

But, before I do, please confirm how this routine deals with parameters inside dynamic blocks? Is it safe and keeps actions? And secondly, although I could read it from the first three lines of the code, will it go in deep with nested blocks?

 

As far as I know the program shouldn't cause any problems when processing dynamic blocks, but of course, all code is always provided 'as is' and should be used with caution. The program I have posted above will remove zero-length and duplicate lines from all Layouts and within all standard and dynamic blocks (excluding XRefs), nested to any level deep.

Link to comment
Share on other sites

Hey, and the very last thing:

In this routine what the criteria defining a duplicate line are? Overkill provides selective criteria like: layer, color, linetype, plotstyle etc.

For example: in a drawing we have two similar overlapping lines but on different layer, for representation of drawing in different scales. Hopefully those two won't be taken for duplicates?

Overkill also works on polylines, does this routine clean those too?

I have tried out the routine in a copy of recovered file, and it works removing huge amount of zero-length and duplicates lines! That would be great, but to be clear, could you describe the criteria of choice?

Link to comment
Share on other sites

In this routine what the criteria defining a duplicate line are?

 

The program defines a duplicate line as a line whose start and end points (in order) equal the start and end points of another line in the drawing or block to the tolerance specified, irrespective of object properties (such as layer etc.).

 

This program is not overkill and doesn't use that command. ;)

Link to comment
Share on other sites

I have checked the linekill in an example drawing I've made for this purpose, containing same line overlapping on three different layers. It removes all duplicates, no matter the layer. So it may be a problem for our more complicated, multipurpose drawings. Actually I need only true duplicates removed, lines, polylines, arc etc. When it removes all similar lines, no matter the layer, how to know which layer will it preserve finally?

 

Lee Mac, would you like to try refine this code to obtain those goals I have described? Or is there already an other lisp that could do that work inside blocks and nested blocks?

 

Postscript: linekill as it is now has resulted useful for our college in the office, who says it does great job for their standard of drawings. :-D So it's been a great contribution too! Many thanks.

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