Author Topic: [XDrX-PlugIn(148)] Erase polylines with length 0 and a single vertex  (Read 78 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 504
Code: [Select]
(defun c:xdtb_plerase0len (/ nums progress ss x)
  (xdrx-begin)
  (if (setq ss (xdrx-ssget (xdrx-string-multilanguage "\n选择要处理的多段线[ALL-全选]<退出>:" "\nSelect the polylines to be processed [ALL-Select All] <Exit>:")
   '((0 . "*polyline"))
       )
      )
    (progn
      (xdrx_statusbar_begin (xdrx-string-multilanguage "处理中..." "Procesing...") (sslength ss))
      (setq progress 0
    nums 0
      )
      (mapcar
'(lambda (x)
   (xdrx_statusbar_setpos (setq progress (1+ progress)))
   (if (equal (xdrx-getpropertyvalue x "length") 0.0 1e-4)
     (progn
       (setq nums (+ nums 1))
       (xdrx-entity-delete x)
     )
   )
)
(xdrx-ss->ents ss)
      )
      (xdrx-statusbar-end)
      (if (> nums 0)
(xdrx-prompt (xdrx-string-formatex (xdrx-string-multilanguage "\n共搜索到 %d 个长度为0的多段线,已经删除." "\nA total of %d polylines with a length of 0 were found and have been deleted.")
   nums
     )
)
(xdrx-prompt (xdrx-string-multilanguage "\n图中未发现长度为0的多段线."
"\nNo polyline with length 0 was found."
     )
)
      )
    )
  )
  (xdrx-end)
  (princ)
)
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net