Join polylines, arcs, lines that are different Gaps

Join polylines, arcs, lines that are different Gaps

hosneyalaa
Advisor Advisor
3,619 Views
4 Replies
Message 1 of 5

Join polylines, arcs, lines that are different Gaps

hosneyalaa
Advisor
Advisor

Hello all
I have a FOUNDATIONS drawing with sporadic lines with spaces of different Gaps
Is it possible to help to connect the lines to get one Poly-line FOR bases

Capture.JPG

 

I found the Gaps code
Could it be modified to get the desired result

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-and-mark-gaps-lisp-repair/m-p/5...

 

vl-load-com)
(defun c:demo (/ *error* get_glob_real mk_circle flag hnd i lst obj ori pt pt1 pt2 ss ss1 ss2)

   (defun *error* (msg)
      (if command-s
         (progn (command-s "_.-view" "_R" "temp_h")
                (command-s "_.-view" "_D" "temp_h")
         )
         (vl-cmdf "_.-view" "_R" "temp_h" "_.-view" "_D" "temp_h")
      )
      (vla-endundomark acdoc)
      (cond ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
      )
      (princ)
   )

   (defun get_glob_real (var msg mod prec def / tmpH)
      (if (or (not var) (/= (type var) 'REAL))
         (setq var def)
      )
      (initget 6)
      (setq tmpH (getreal (strcat "\n" msg " <" (rtos var mod prec) ">: ")))
      (if (/= tmpH nil)
         (setq var tmpH)
      )
      var
   )

   (defun mk_circle (pt dia)
      (entmake
         (list
            '(0 . "CIRCLE")
            '(8 . "GAP")
            (cons 10 pt)
            (cons 40 (/ dia 2.0))
            '(62 . 1)
         )
      )
   )

   (or acdoc (setq acdoc (vla-get-activedocument (vlax-get-acad-object))))
   (vla-startundomark acdoc)
   (vl-cmdf "_.-view" "_S" "temp_h" "_.ucs" "_W")
   (if (and (setq *_max_fuzz (get_glob_real *_max_fuzz "\n Enter Maximum Gap" 2 3 1.00))
            (setq *_min_fuzz (get_glob_real *_min_fuzz "\n Enter Minimum Gap" 2 3 0.001))
            (setq *_dia (get_glob_real *_dia "\n Enter Circle Size" 2 2 0.50))
            (princ "\n Select objects or <ENTER> for all: ")
            (or (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE"))))
                (setq ss (ssget "_X" (list '(0 . "ARC,LINE,*POLYLINE,SPLINE") (cons 410 (getvar 'ctab)))))
            )
       )
      (progn
         (repeat (setq i (sslength ss))
            (setq hnd (ssname ss (setq i (1- i)))
                  lst (cons (vlax-curve-getstartpoint hnd) lst)
                  lst (cons (vlax-curve-getendpoint hnd) lst)
            )
         )
         (while lst
            (setq pt  (car lst)
                  lst (cdr lst)
            )
            (if (not (vl-some '(lambda (p) (equal p pt *_min_fuzz)) lst))
               (if (and (vl-cmdf "_.zoom"
                                 (setq pt1 (list (- (car pt) *_max_fuzz) (- (cadr pt) *_max_fuzz)))
                                 (setq pt2 (list (+ (car pt) *_max_fuzz) (+ (cadr pt) *_max_fuzz)))
                        )
                        (setq ss1 (ssget "_C" pt1 pt2 '((0 . "ARC,LINE,*POLYLINE,SPLINE"))))
                   )
                  (if (setq ss2 (ssget "_C" pt pt '((0 . "ARC,LINE,*POLYLINE,SPLINE"))))
                     (progn
                        (repeat (setq i (sslength ss2))
                           (setq hnd  (ssname ss2 (setq i (1- i)))
                                 obj  (vlax-ename->vla-object hnd)
                                 pt_a (vlax-curve-getstartpoint hnd)
                                 pt_b (vlax-curve-getendpoint hnd)
                           )
                           (if (or (equal pt_a pt 1e-6)
                                   (equal pt_b pt 1e-6)
                               )
                              (setq ori hnd)
                           )
                        )
                        (setq flag nil)
                        (repeat (setq i (sslength ss1))
                           (setq hnd (ssname ss1 (setq i (1- i)))
                                 obj (vlax-ename->vla-object hnd)
                           )
                           (if (and (ssmemb hnd ss)
                                    (not (eq ori hnd))
                                    (<= (distance (vlax-curve-getClosestPointTo obj pt) pt) *_min_fuzz)
                               )
                              (setq flag T)
                           )
                        )
                        (if (null flag)
                           (repeat (setq i (sslength ss1))
                              (setq hnd (ssname ss1 (setq i (1- i)))
                                    obj (vlax-ename->vla-object hnd)
                              )
                              (if (ssmemb hnd ss)
                                 (progn
                                    (if (and (not (eq ori hnd))
                                             (<= *_min_fuzz (distance pt (vlax-curve-getClosestPointTo obj pt)) *_max_fuzz)
                                        )
                                       (mk_circle pt *_dia)
                                    )
                                    (if (and (eq ori hnd)
                                             (wcmatch (vla-get-objectname obj) "*Polyline,*Spline")
                                             (= (vla-get-closed obj) :vlax-false)
                                             (> (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)) *_max_fuzz)
                                             (<= *_min_fuzz (distance (vlax-curve-getStartPoint obj) (vlax-curve-getEndPoint obj)) *_max_fuzz)
                                        )
                                       (mk_circle pt *_dia)
                                    )
                                 )
                              )
                           )
                        )
                     )
                  )
               )
            )
            (setq lst (vl-remove-if '(lambda (p) (equal p pt *_min_fuzz)) lst))
         )
      )
   )
   (*error* nil)
   (princ)
)

 

0 Likes
Accepted solutions (1)
3,620 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

No need for programming anything.

Using the MPEDIT is a job done in a matter of seconds.

See HERE 

0 Likes
Message 3 of 5

hosneyalaa
Advisor
Advisor

TANK YOU @ВeekeeCZ 

FOR reply

But the problem with the vertexS will be many
A question
Can I put every group of asymptotes  LINES in a listS
Then it was operated on later

CaptureW.JPG

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

But you got what you've asked for, haven't you?

Z9E3zK5E_0-1614862584336.png

 

 

Anyway, you may fix most of it using @Kent1Cooper 's PLDiet routine. 

Message 5 of 5

pbejse
Mentor
Mentor

@ВeekeeCZ wrote:

Anyway, you may fix most of it using @Kent1Cooper 's PLDiet routine. 


 

For real? I had to look it up :D,  Like thats the best name ever!

What a hero .👍

 

 

0 Likes