Results 1 to 3 of 3

Thread: A lisp to draw lines between endpoints

  1. #1
    Member
    Join Date
    2017-06
    Posts
    2
    Login to Give a bone
    0

    Lightbulb A lisp to draw lines between endpoints

    I don't know much about autolisp, so any help is appreciated

    I have a group of broken lines and i need to draw a line between each two endpoints within a fuzz distance of my choice.

    Just a simple line. No joining or anything.

    Thanks in advance

  2. #2
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: A lisp to draw lines between endpoints

    Code:
    (defun c:linesbtwbrokenlines ( / ss fuzz i lix pl p pp )
    
      (prompt "\nSelect broken lines...")
      (setq ss (ssget '((0 . "LINE"))))
      (initget 6)
      (setq fuzz (getdist "\nPick or specify fuzz distance <0.1> : "))
      (if (null fuzz)
        (setq fuzz 0.1)
      )
      (if ss
        (progn
          (repeat (setq i (sslength ss))
            (setq lix (entget (ssname ss (setq i (1- i)))))
            (setq pl (cons (cdr (assoc 10 lix)) pl) pl (cons (cdr (assoc 11 lix)) pl))
          )
          (foreach p pl
            (if (vl-member-if (function (lambda ( x ) (equal p x 1e-6))) (vl-remove p pl))
              (setq pl (vl-remove-if (function (lambda ( x ) (equal p x 1e-6))) pl))
            )
          )
          (while (setq p (car pl))
            (if (<= 0.0 (distance p (setq pp (cadr (vl-sort pl (function (lambda ( a b ) (< (distance a p) (distance b p)))))))) fuzz)
              (progn
                (entmake (list '(0 . "LINE") (cons 10 p) (cons 11 pp)))
                (setq pl (vl-remove p pl) pl (vl-remove pp pl))
              )
              (setq pl (cdr pl))
            )
          )
        )
      )
      (princ)
    )
    HTH., M.R.

  3. #3
    Member
    Join Date
    2017-06
    Posts
    2
    Login to Give a bone
    0

    Default Re: A lisp to draw lines between endpoints

    It worked!!

    Thank you

Similar Threads

  1. Need to create points at endpoints for selected lines with the same layers
    By brahmanandam.thadikonda762224 in forum AutoLISP
    Replies: 6
    Last Post: 2019-02-22, 05:40 PM
  2. Compare line endpoints to points and adjust lines
    By GreyHippo in forum AutoLISP
    Replies: 5
    Last Post: 2018-08-15, 09:20 AM
  3. Add Draw Order/Lines Merge/Lines Overwrite settings to layer properties
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2013-10-25, 01:57 AM
  4. Replies: 1
    Last Post: 2011-11-18, 03:45 PM
  5. Lisp to draw right angle lines?
    By Shawnc in forum AutoLISP
    Replies: 8
    Last Post: 2005-10-17, 11:06 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
  •