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
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
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.
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
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
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.
I ran it and it gives me an automation error. Object is referenced. Thanks for the help though.
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?
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.
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.
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) ) )
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
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.