Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can not purge blocks

13 REPLIES 13
Reply
Message 1 of 14
RyanElam
3652 Views, 13 Replies

Can not purge blocks

I have a file with 403 blocks in it that can not be deleted, purged, or seen.  I've attempted to WBLOCK the linework out, copy and paste the linework out, exploding every object in the file, changing everything to bylayer and layer 0, purgeing and -purgeing, but the blocks are still there along with a number of linestyles associated with the hidden blocks.  Is there any way to get rid of these blocks?  I have a file attached with nothing else in it except the blocks I cannot purge.  They are also not associated with any styles.  Any help would be greatly appreciated.

 

Thanks,

Ryan

 

Ryan

Civil 3D 2013
Tags (3)
13 REPLIES 13
Message 2 of 14
troma
in reply to: RyanElam

What happens if you use QuickSelect to select all instances of one of the blocks, and delete.  Can it then be purged?  Not something you want to do 403 times, but as a test.

 

You could try a couple of searches for a deep purge or super purge lisp routine.  There might be something out there to help you.


Mark Green

Working on Civil 3D in Canada

Message 3 of 14
RyanElam
in reply to: troma

Quick select is not available.  The file doesn't appear to have any objects in it.  The blocks only show up under the items that you cannot purge.

Ryan

Civil 3D 2013
Message 4 of 14
jrauch
in reply to: RyanElam

This would work, but it's dangerous.  It deletes every block definition from your drawing.  It doesn't check to see if the block is in use or anything, it just deletes all block definitions.  So it would completely hose most drawings.

 

(setq acad (vlax-get-acad-object))
(setq doc (vla-get-activedocument acad))
(setq blocks (vla-get-blocks doc))

(while     (> (vla-get-count blocks) 2); blocks 0 and 1 are modelspace and paperspace
    (setq b1 (vla-item blocks 2))

;; This is where you'd put filters to weed out blocks you want to keep

    (vlax-invoke-method b1 'delete)
)

(vlax-release-object blocks)
(vlax-release-object doc)
(vlax-release-object acad)

 Hope this helps!

John

-John J. Rauch, P.E.
Message 5 of 14
RyanElam
in reply to: jrauch

Would I just type the code in the command line?  I don't have that much coding experience.

Ryan

Civil 3D 2013
Message 6 of 14
troma
in reply to: RyanElam

I think copy/paste in commandline will work.

 

 

If you want to save it as a routine, you can put the text in notepad, save it with the file extention .lsp

Then you need to type appload in autocad, browse to the .lsp file and load it.

But I think there may be more lines required in the code for it to work that way.


Mark Green

Working on Civil 3D in Canada

Message 7 of 14
jrauch
in reply to: RyanElam

You can copy and paste it in at the command line (do it all in one shot, not line-by-line). 

 

But this is like a last resort thing.  I would recommend you try to find out what these things are and how they were created.  If purge doesn't want to delete them, there's probably a reason.  Though I did look through the drawing and couldn't find anything. 

 

If you're just looking for a blank slate, try creating a drawing with acad.dwt. 

 

Running this routine could potentially do more harm than good, which is why I didn't write it into a function.  I hesitate using it once, let alone setting it up to be used repeatedly.

-John J. Rauch, P.E.
Message 8 of 14
RyanElam
in reply to: jrauch

I ran it and it gives me an automation error. Object is referenced.  Thanks for the help though.

Ryan

Civil 3D 2013
Message 9 of 14
jrauch
in reply to: RyanElam

You know what - when I ran that successfully, it was after I had exported your drawing to AutoCAD.  Export to AutoCAD removes all Civil3D objects from a drawing.

 

Why are you doing this anyway?

-John J. Rauch, P.E.
Message 10 of 14
Jeff_M
in reply to: RyanElam

Ryan, in the same vein as what John mentioned, try this bit of lisp: (I did test it on your drawing without error)

 

(vl-load-com)

(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(if (= (vla-get-islayout blk) :vlax-false)
(vla-delete blk)
)
)

 

This makes sure to not include the Modelspace or any Paperspace objects. From the looks of the drawing, I think that an Xref containing anonymous Groups was Inserted/Bound to the drawing and something triggered them as being unpurgable, although I'm not sure what that could have been.

 

Oh, and I ran it from the C3D as AutoCAD icon, not inside C3D.

Jeff_M, also a frequent Swamper
EESignature
Message 11 of 14
RyanElam
in reply to: jrauch

We recieved some files from an architect and they contained a bunch of stuff that has been since embeded into our base files.  It's making our drawings incredibly slow and frustrating the entire team.  We are way too far along to try and re-build new line work.  Copying our likework out and wblocking have all resulted in these entities being carried through.

Ryan

Civil 3D 2013
Message 12 of 14
Jeff_M
in reply to: RyanElam

And here's another, safer, variation that will only remove the blocks created by Group:

(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
  (if (wcmatch (vla-get-name blk) "`*A*")
    (vla-delete blk)
    )
  )

 Or another that does the Group blocks and Anonymous blocks:

 

(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
  (if (wcmatch (vla-get-name blk) "`*A*,`*U*")
    (vla-delete blk)
    )
  )

 

Jeff_M, also a frequent Swamper
EESignature
Message 13 of 14
troma
in reply to: Jeff_M

Here's one that explodes anonymous blocks, something that was driving me nutty:

 

(defun c:test (/ ss old-echo item ss1 item1)
  (setq old-echo (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (if (setq ss (ssget '((2 . "`*U*"))))
    (foreach item (mapcar 'cadr (ssnamex ss))
      (command "Explode" item)
      (while
	(setq ss1 (ssget "_P" '((2 . "`*U*"))))
	 (foreach item1	(mapcar 'cadr (ssnamex ss1))
	   (command "Explode" item1)
	 )
      )
    )
  )
  (setq ss nil)
  (setq ss1 nil)
  (setvar "CMDECHO" old-echo)
  (princ)
)

 Don't know if that is related or not.


Mark Green

Working on Civil 3D in Canada

Message 14 of 14
RyanElam
in reply to: troma

I ended up exporting the linework base file I had to a DXF file and then brought it back in.  This allowed me to then purge all of the blocks I was unable to see or purge before.  I'm not sure if that's the best way to do it, but nothing else was working.  Luckily I didn't have to do something like that to a file that had any built in intelligence, it was just lines.  Thanks for everyone's help.

Ryan

Civil 3D 2013

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report