liuhaixin88 Posted March 9, 2014 Posted March 9, 2014 If use lisp ,how to purge zero-length geometry and empty text objects? Thanks for help! Quote
Tharwat Posted March 9, 2014 Posted March 9, 2014 If you don't have zero-length geometry or empty text objects in a drawing , it won't be activate it . Quote
Lee Mac Posted March 9, 2014 Posted March 9, 2014 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") Quote
MSasu Posted March 10, 2014 Posted March 10, 2014 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. Quote
Tharwat Posted March 10, 2014 Posted March 10, 2014 Simple sample (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) Quote
liuhaixin88 Posted March 10, 2014 Author Posted March 10, 2014 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. Quote
Tharwat Posted March 10, 2014 Posted March 10, 2014 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 . Quote
flyfox1047 Posted March 12, 2014 Posted March 12, 2014 Simple sample (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) ) ) Quote
flyfox1047 Posted March 13, 2014 Posted March 13, 2014 What about objects in Layouts ? (vlax-for obj (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object))) .... ) Quote
Tharwat Posted March 13, 2014 Posted March 13, 2014 I am not asking you for a solution but to show you that iterating database is more direct that iterating each space alone . Quote
irneb Posted March 13, 2014 Posted March 13, 2014 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? Quote
Tharwat Posted March 13, 2014 Posted March 13, 2014 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 Quote
liuhaixin88 Posted March 13, 2014 Author Posted March 13, 2014 Exactly , thanks for the intervention irneb 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) ) Quote
Tharwat Posted March 14, 2014 Posted March 14, 2014 Can you write a sample ? I was pleasantly surprised to see your code. I already did , did not you try it ? Quote
Recommended Posts
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.