Jump to content

Recommended Posts

Posted

If use lisp ,how to purge zero-length geometry and empty text objects? Thanks for help!

purge.jpg

Posted

If you don't have zero-length geometry or empty text objects in a drawing , it won't be activate it .

Posted
Command: -PURGE
Enter type of unused objects to purge [blocks/DEtailviewstyles/Dimstyles/Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/SEctionviewstyles/Tablestyles/Visualstyles/Regapps/[color=red]Zero-length geometry[/color]/[color=red]Empty text objects[/color]/All]:

(command "_.-purge" "_Z" "_.-purge" "_E")

Posted

Since you mentioned AutoLISP, are you intending to write your own code to do so? If yes, then to find zero length entities will need to look for VLA-GET-LENGTH function:

(vla-get-length (vlax-ename->vla-object (car (entsel))))

An empty text entity will have an empty string stored under DXF code 1 in its associated lists.

 

For sure all of the above will require parsing the drawing's database - please check the ENTNEXT and ENTGET functions.

Posted

Simple sample :D

 

(setq ss (ssadd)
     e  (entnext)
)
(while (and e (wcmatch (cdr (assoc 0 (setq en (entget e)))) "LINE,LWPOLYLINE,*TEXT"))
 (if (or (and (vlax-property-available-p (setq v (vlax-ename->vla-object e)) 'LENGTH)
              (zerop (vla-get-length v))
         )
         (and (vlax-property-available-p v 'TEXTSTRING) (eq (vla-get-textstring v) ""))
     )
   (ssadd e ss)
 )
 (setq e (entnext e))
)
(sssetfirst nil ss)

Posted

Lee Mac,MSasu,Tharwat,

Thank you!

If use PURGE,but Low version does not have this option,eg.acad2007

Tharwat ,thank you for your code.

Posted

If use PURGE,but Low version does not have this option,eg.acad2007

 

That's why I wrote that simple code for ;)

 

Tharwat ,thank you for your code.

 

You're welcome .

Posted
Simple sample :D

 

(setq ss (ssadd)
     e  (entnext)
)
(while (and e (wcmatch (cdr (assoc 0 (setq en (entget e)))) "LINE,LWPOLYLINE,*TEXT"))
 (if (or (and (vlax-property-available-p (setq v (vlax-ename->vla-object e)) 'LENGTH)
              (zerop (vla-get-length v))
         )
         (and (vlax-property-available-p v 'TEXTSTRING) (eq (vla-get-textstring v) ""))
     )
   (ssadd e ss)
 )
 (setq e (entnext e))
)
(sssetfirst nil ss)

 

(vlax-for obj (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
  (setq typ (vla-get-objectname obj))
  (cond 
    ((wcmatch typ "*Text")
      ....
    ((wcmatch (strcase typ) "*LINE,ARC,ELLIPSE")
    ....
    )
   (t)
  )
)

Posted
What about objects in Layouts ?

 

(vlax-for obj (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object)))
 ....
)

Posted

I am not asking you for a solution but to show you that iterating database is more direct that iterating each space alone . ;)

Posted

Of course, if you also want to step through blocks, then it's even easier - you can simply iterate through the document's blocks collection. This would then (in addition to user created blocks) iterate over the model space as well as all paper space tabs.

 

To add to what Tharwat's alluded to: Going with vla-get-paperspace only does the one single tab. What if your DWG has 2 or more paper space tabs?

Posted

To add to what Tharwat's alluded to: Going with vla-get-paperspace only does the one single tab. What if your DWG has 2 or more paper space tabs?

 

Exactly , thanks for the intervention irneb :thumbsup:

Posted
Exactly , thanks for the intervention irneb :thumbsup:

 

Can you write a sample ? I was pleasantly surprised to see your code.

 

(defun c:tt ()
(setvar "CMDECHO" 0)
(vl-load-com)
(setq ss (ssget "X" '((0 . "LINE,LWPOLYLINE,*TEXT"))))
(setq i -1)
(repeat (sslength ss)
(setq e (ssname ss (setq i (1+ i))))
 (if (or (and (vlax-property-available-p (setq v (vlax-ename->vla-object e)) 'LENGTH)
          (zerop (vla-get-length v))
     )
         (and
          (vlax-property-available-p v 'TEXTSTRING)
          (eq (vl-string-left-trim " " (vla-get-textstring v)) ""))
       )
 (entdel e)
 )
)
(setvar "CMDECHO" 1)
(princ)
)

Posted
Can you write a sample ? I was pleasantly surprised to see your code.

 

I already did , did not you try it ?

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