Results 1 to 4 of 4

Thread: Search for and delete polylines based on length.

  1. #1
    I could stop if I wanted to
    Join Date
    2015-10
    Posts
    215
    Login to Give a bone
    0

    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
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    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 11:46 AM. Reason: Retard Moment

  3. #3
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    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

  4. #4
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    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. Total Length of Polylines
    By vijaybaskergundla in forum AutoLISP
    Replies: 7
    Last Post: 2015-04-30, 04:29 PM
  2. Polylines and Total Length
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 3
    Last Post: 2012-06-13, 08:10 PM
  3. Length of polylines within an area
    By .T. in forum AutoLISP
    Replies: 53
    Last Post: 2009-10-08, 12:47 AM
  4. LENGTH and area of many polylines
    By marijan.marsic in forum AutoLISP
    Replies: 16
    Last Post: 2008-12-02, 08:50 AM
  5. Get total length of selected Polylines
    By roygoncalves in forum AutoCAD General
    Replies: 4
    Last Post: 2006-11-07, 12:37 PM

Posting Permissions

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