When I zoom extents it zooms out too far. I can see a small rectangle that looks like text when you zoom out to far, but I can't select it or edit it.
I figured out what it was by following these steps. I typed QTEXT and turned it on. Then I could see the outline of a box. When I open the Attribute Editor I see that the block is WD_WNV which is the vertical wire number block in AutoCAD Electrical. The value of the WIRENO attribute is three spaces. Because it is just spaces you do not see any grips on the block but when you zoom extents, AutoCAD still knows it is there and includes it in the extents.
At this point I could just delete the block, or delete the spaces so it is blank. The problem is that we have thousands of drawings that have this block there (because we always copy old designs to start new ones). I am trying to find a solution that will work system-wide, or a command I can run upon opening each drawing that will delete the block.
All of these drawings were created in AutoCAD LT, I have no idea how the WD_WNV block made it's way into these drawings. It is interesting that AutoCAD LT 2019 does not see this block when zooming extents, but AutoCAD Electrical 2021 does see it. Also of note, we have one user that zoom extents doesn't see the block in AutoCAD Electrical.
I thought that maybe I could run a Find and Replace every time I open a drawing and replace the three spaces with nothing but the command will not replace it if it leaves the text empty.
I also thought we could run a Block Swap on startup to replace that block and select the option to discard all old attribute values. However, this would remove any valid vertical wire numbers in AutoCAD Electrical drawings.
Does anyone know of a way to edit this block easily on thousands of drawings? Or, is there some LISP we could run on startup to edit the block? Is it possible to exclude a specific layer from consideration of the Zoom Extents (without freezing the layer)? Open to any ideas. Thanks in advance, sorry for the long question. I will attach an example drawing if anyone wants to look at it.
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Solved by pbejse. Go to Solution.
@Anonymous wrote:
....
At this point I could just delete the block, or delete the spaces so it is blank. The problem is that we have thousands of drawings that have this block there (because we always copy old designs to start new ones). I am trying to find a solution that will work system-wide, or a command I can run upon opening each drawing that will delete the block.
Here's a short program that you can run from startup. The code checks all attribute blocks, if and only if ALL of the attribute values evaluates to "" then it will deleted, Any of the values that only have space(s) " " will be converted to "" during evaluation.
It accepts any number of block names.
(defun _DelBlockWithEmptyAttributes (l)
(vlax-for layout (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for i (vla-get-block layout)
(if (and
(vlax-write-enabled-p i)
(= (vla-get-objectname i) "AcDbBlockReference")
(minusp (vlax-get i "HasAttributes"))
(member (strcase (vla-get-effectivename i)) l)
(vl-every '(lambda (at)
(eq (vl-string-trim " " (vla-get-textstring at)) ""))
(vlax-invoke i 'GetAttributes)
)
(vlax-write-enabled-p i)
)
(vla-Delete i)
)
)
)
)
You call it like this [ notice all the names are in uppercase ]
(_DelBlockWithEmptyAttributes '("WD_WNV" "PBEBLOCK"))
Or if you want this exclusively to work ONLY with "WD_WNV" block.
(defun c:DeleteBlankWD_WNV ()
(vlax-for layout (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for i (vla-get-block layout)
(if (and
(vlax-write-enabled-p i)
(= (vla-get-objectname i) "AcDbBlockReference")
(minusp (vlax-get i "HasAttributes"))
(eq (strcase (vla-get-effectivename i)) "WD_WNV")
(vl-every '(lambda (at)
(eq (vl-string-trim " " (vla-get-textstring at)) ""))
(vlax-invoke i 'GetAttributes)
)
(vlax-write-enabled-p i)
)
(vla-Delete i)
)
)
)
)
command: DeleteBlankWD_WNV
Run this on your drawing and tell me how it goes.
HTH
Hi Kamron,
I'm sure you are aware a regular purge on the command prompt can also delete empty strings. [ Text/Mtext ]
(command "-purge" "e")
or thru ssget
(if
(setq ss (ssget "_X" '((0 . "*TEXT") (1 . " ,"))))
(mapcar '(lambda (x) (entdel (cadr x))) (ssnamex ss))
)
For the sake of completeness, we will include that option on the previous code.
(defun c:DeleteBlankWD_WNV nil
(vlax-for layout (vla-get-layouts
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(vlax-for i (vla-get-block layout)
(cond
((and
(vlax-write-enabled-p i)
(member (vla-get-objectname i)
'("AcDbMText" "AcDbText" "AcDbBlockReference")
)
(or
(and
(vlax-property-available-p i "HasAttributes")
(minusp (vlax-get i "HasAttributes"))
(eq (strcase (vla-get-effectivename i)) "WD_WNV")
(vl-every
'(lambda (at)
(eq (vl-string-trim " " (vla-get-textstring at)) "")
)
(vlax-invoke i 'GetAttributes)
)
)
(and
(vlax-property-available-p i "TextString")
(eq (vl-string-trim " " (vla-get-textstring i)) "")
)
)
)
(vla-Delete i)
)
)
)
)
)
Main reason why the code is written in VL so you may also use this for mulitple drawing files, not just by script but also with ObjectDBX.
HTH
Can't find what you're looking for? Ask the community or share your knowledge.