+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
  1. #1
    Senior Member martinle's Avatar
    Computer Details
    martinle's Computer Details
    Operating System:
    windows 10
    Using
    AutoCAD 2018
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    157

    Default connected polylines corners

    Registered forum members do not see this ad.

    Hello
    Please help!
    I can not lisp.
    Seeking a way with a lisp to connect the corners of a closed polyline.
    These polylines are always so similar to the example.
    There are very many such lines and it would be great if you could solve with a lisp.
    Thank you!
    Martin
    Attached Images
    My friend has the Google Translator

  2. #2
    Senior Member
    Discipline
    Structural
    Using
    AutoCAD 2014
    Join Date
    Sep 2011
    Location
    Baia Mare, Romania
    Posts
    378

    Default

    Hi Martin

    Try this, but be aware that it will fail if there are duplicate points or if any partial distance is shorter that the "offset" distance.
    Code:
    (defun connect (e / _point d d1 l p1 p2 a b n i)
      (setq _point vlax-curve-getpointatparam
            d (vlax-curve-getdistatparam e (setq n (fix (+ 0.1 (vlax-curve-getendparam e))))))
      (repeat (setq i (1+ n))
        (setq l (cons (setq p1 (_point e (setq i (1- i)))) l))
        (if
          (setq p2 (cadr l))
          (if
            (and
              (< (setq d1 (distance p1 p2)) d)
              (not (zerop d1))
            )
            (setq
              d d1
              a (rem (1+ i) n)
              b i
              )
            )
          )
        )
      (mapcar 'set '(a b) (list (max a b) (min a b)))
      (while
        (progn
          (setq a (rem (1+ a) n))
          (setq b (rem (+ n (1- b)) n))
          (not (= (rem (1+ a) n) b))
        )
        (entmake
          (list
            '(0 . "LINE")
            (cons 10 (_point e a))
            (cons 11 (_point e b))
            )
          )
        )
      )
    
    (defun c:test (/ ss i)
      (if
        (setq ss (ssget '((0 . "LWPOLYLINE"))))
        (repeat (setq i (sslength ss))
          (connect (ssname ss (setq i (1- i))))
          )
        )
      (princ)
      )

  3. #3
    Senior Member martinle's Avatar
    Computer Details
    martinle's Computer Details
    Operating System:
    windows 10
    Using
    AutoCAD 2018
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    157

    Default

    Hello Stefan!

    That's awesome !!
    Many thanks.
    It works wonderfully!


    Thank you!
    Martin
    My friend has the Google Translator

  4. #4
    Forum Deity
    Using
    AutoCAD 2002
    Join Date
    Sep 2006
    Location
    East Sussex, U.K.
    Posts
    4,058

    Default

    Just in case you would like an alternative which does not use lisp, draw a polyline at the centre, give it a width, and turn Fill off. The effect is the same
    Attached Images

  5. #5
    Senior Member martinle's Avatar
    Computer Details
    martinle's Computer Details
    Operating System:
    windows 10
    Using
    AutoCAD 2018
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    157

    Default

    Hi Eldon

    My polylines exist already.
    Only the corner joints are still missing.

    thank you

    Martin
    My friend has the Google Translator

  6. #6
    Senior Member
    Discipline
    Structural
    Using
    AutoCAD 2014
    Join Date
    Sep 2011
    Location
    Baia Mare, Romania
    Posts
    378

    Default

    You're welcome Martin

    Duplicate points bug removed
    Code:
    (defun connect (e / _point d d1 p1 p2 p11 p12 p21 p22 a b n i)
      (setq _point vlax-curve-getpointatparam
            d (vlax-curve-getdistatparam e
                (setq n (fix (+ 0.1 (vlax-curve-getendparam e))))
              )
            )
      (repeat (setq i (1+ n))
        (setq p1 (_point e (setq i (1- i))))
        (if p2
          (if
            (and
              (< (setq d1 (distance p1 p2)) d)
              (not (zerop d1))
            )
            (setq
              d d1
              a (rem (1+ i) n)
              b i
              )
            )
          )
        (setq p2 p1)
        )
      (if (zerop b) (mapcar 'set '(a b) (list b a)))
      (setq p11 (_point e a)
            p21 (_point e b)
            )
      (while
        (progn
          (while
            (equal p11 (setq p12 (_point e (setq a (rem (1+ a) n)))) 1e-8)
            )
          (while
            (equal p21 (setq p22 (_point e (setq b (rem (+ n (1- b)) n)))) 1e-8)
            )
          (not
            (or
              (= (abs (- a b)) 1)
              (= (abs (- a b)) n)
            )
          )
        )
        (entmake
          (list
            '(0 . "LINE")
            (cons 10 (setq p11 p12))
            (cons 11 (setq p21 p22))
            )
          )
        )
      )
    
    (defun c:test (/ ss i)
      (if
        (setq ss (ssget '((0 . "LWPOLYLINE"))))
        (repeat (setq i (sslength ss))
          (connect (ssname ss (setq i (1- i))))
          )
        )
      (princ)
      )
    Last edited by Stefan BMR; 18th Feb 2016 at 01:11 pm. Reason: Updated

  7. #7
    Senior Member martinle's Avatar
    Computer Details
    martinle's Computer Details
    Operating System:
    windows 10
    Using
    AutoCAD 2018
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    157

    Default

    Hello Stefan!
    Many thanks.


    Thank you!
    Martin
    My friend has the Google Translator

  8. #8
    Senior Member martinle's Avatar
    Computer Details
    martinle's Computer Details
    Operating System:
    windows 10
    Using
    AutoCAD 2018
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    157

    Default

    Hello Stefan,

    One small thing is I have noticed.
    There are drawn all the oblique connections.
    But also a connection to the straight end of the polyline.
    Would it still possible that you will not use it to create any line on the other is?
    That would be great!

    Many thanks!

    Martin
    My friend has the Google Translator

  9. #9
    Senior Member martinle's Avatar
    Computer Details
    martinle's Computer Details
    Operating System:
    windows 10
    Using
    AutoCAD 2018
    Join Date
    Mar 2010
    Location
    Austria
    Posts
    157

    Default

    sorry for my bad English
    My friend has the Google Translator

  10. #10
    Senior Member
    Discipline
    Structural
    Using
    AutoCAD 2014
    Join Date
    Sep 2011
    Location
    Baia Mare, Romania
    Posts
    378

    Default

    Registered forum members do not see this ad.

    Updated previous post.
    I'm not sure I have covered all the possibilities, I will check again later.

Similar Threads

  1. conduit connectors shown as 'not connected'
    By Ravenstown in forum MEP
    Replies: 1
    Last Post: 18th Jan 2014, 12:52 pm
  2. Join two connected solid hatches
    By satishrajdev in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 24th Nov 2012, 04:45 pm
  3. Two Polylines Not Joining at corners
    By CadDan in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 27th Jul 2009, 07:43 pm
  4. Making Sure Lines Are Truly Connected
    By Shanna in forum AutoCAD General
    Replies: 28
    Last Post: 24th Oct 2007, 02:21 am
  5. Thick polylines don't appear to join at the corners
    By cjhornet in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 7th Jul 2007, 11:05 am

Bookmarks

Posting Permissions

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