Results 1 to 4 of 4

Thread: Search for and delete polylines based on length.

  1. #1
    100 Club mikehaff's Avatar
    Join Date
    2010-10
    Posts
    196
    0 Did you find this post helpful? Yes

    Default Search for and delete polylines based on length.

    I downloaded the following code from The Swamp. It searches for and deletes lines whose lengths fall between 1.25" and 3.0". It was submitted as a solution to someone else's problem by Tharwat. It works as advertised. However, my situation is slightly different. Changing the length parameters are easy enough. I need to search for LWPolylines of a specific length. How could I modify this code to do that? I'm wondering if it is even possible.

    Code:
    (defun c:Test (/ ss i sn l)
      (if (setq ss (ssget "_:L" '((0 . "LINE"))))
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (setq l (distance (cdr (assoc 10 (entget sn))) (cdr (assoc 11 (entget sn)))))
          (if (or (eq l 1.25) (eq l 3.0) (and (> l 1.25) (< l 3.0)))
            (entdel sn)
            )
          )
        )
      (princ)
      )

  2. #2
    All AUGI, all the time pbejse's Avatar
    Join Date
    2010-10
    Posts
    501
    0 Did you find this post helpful? Yes

    Default Re: Search for and delete polylines based on length.

    Quote Originally Posted by mikehaff View Post
    I need to search for LWPolylines of a specific length. How could I modify this code to do that? I'm wondering if it is even possible.
    Not possible with direct SSGET filtering as there are no DXF equivalent for Length, Similar to tharwats code you need to iterate thru the selection set to retrieve the distance like so:

    Code:
    (defun c:Test (/ dist ss i sn l)
      (if (and (setq dist (getdist "\nEnter Polyline Length: "))
    	   (setq ss (ssget "_:L" '((0 . "LWPOLYLINE"))))
          )
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (setq l
    	     (vlax-curve-getdistatpoint
    	       sn
    	       (vlax-curve-getEndPoint sn)
    	     )
          )
          (if (equal l dist 1e-4)
    	(entdel sn)
          )
        )
      )
      (princ)
    )
    HTH
    Last edited by pbejse; 2014-02-08 at 10:46 AM. Reason: Retard Moment

  3. #3
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    565
    0 Did you find this post helpful? Yes

    Default Re: Search for and delete polylines based on length.

    pbejse , you need to recheck the way you retrieved the length of the selected LWpolylines in your modified codes
    Get learn and learn and practice , to become experienced guy .

  4. #4
    All AUGI, all the time pbejse's Avatar
    Join Date
    2010-10
    Posts
    501
    0 Did you find this post helpful? Yes

    Default Re: Search for and delete polylines based on length.

    Quote Originally Posted by Tharwat View Post
    pbejse , you need to recheck the way you retrieved the length of the selected LWpolylines in your modified codes
    You are right!!! Good catch my friend. Post updated [It is a Lwpolyline after all] serves me right not trying out the code before posting.

Similar Threads

  1. Polylines and Total Length
    By Revit Wishes in forum Revit Architecture - Wish List
    Replies: 3
    Last Post: 2012-06-13, 08:10 PM
  2. Length of polylines within an area
    By .T. in forum AutoLISP
    Replies: 53
    Last Post: 2009-10-08, 12:47 AM
  3. LENGTH and area of many polylines
    By marijan.marsic in forum AutoLISP
    Replies: 16
    Last Post: 2008-12-02, 07:50 AM
  4. Total Length of Polylines
    By vijaybaskergundla in forum AutoLISP
    Replies: 5
    Last Post: 2008-11-11, 02:23 AM
  5. Get total length of selected Polylines
    By roygoncalves in forum AutoCAD General
    Replies: 4
    Last Post: 2006-11-07, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •