Jump to content

move lines / polylines liniar (y) to touch polyline


Recommended Posts

Posted

Hello everybody,

 

How can i do that?

Move lines / polylines liniar (y) to touch polyline

 

 

 

 

I'm a drafter not a coder as you might have guessed. :unsure:

 

thx for your time.

move lines.jpg

Posted

This was interesting. However, you should learn to code yourself.

 

(defun c:MLTC (/ #SS #Curve #Int1 #Int2 #Pnt)
 ;; Move Lines to Curve; Alan J. Thompson, 03.16.10
 (vl-load-com)
 (cond
   ((and (princ "\nSelect Line object(s) to move: ")
         (setq #SS (ssget "_:L" '((0 . "LINE,LWPOLYLINE"))))
         (setq #Curve (car (entsel "\nSelect curve to move text to: ")))
         (or (vl-position (cdr (assoc 0 (entget #Curve))) '("LWPOLYLINE" "LINE" "ARC"))
             (alert "Invalid selected object!")
         ) ;_ or
         (setq #Curve (vlax-ename->vla-object #Curve))
    ) ;_ and
    (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*))
      (and (not (eq (vla-get-objectid x) (vla-get-objectid #Curve)))
           (setq #Int1 (vla-intersectwith x #Curve acextendthisentity))
           (setq #Int2 (vlax-safearray->list (vlax-variant-value #Int1)))
           (eq 3 (length #Int2))
           (setq #Pnt (car (vl-sort (list (vlax-curve-getstartpoint x) (vlax-curve-getendpoint x))
                                    '(lambda (a b) (< (distance a #Int2) (distance b #Int2)))
                           ) ;_ vl-sort
                      ) ;_ car
           ) ;_ setq
           (vla-move x (vlax-3d-point #Pnt) #Int1)
      ) ;_ and
    ) ;_ vlax-for
    (vla-delete #SS)
   )
 ) ;_ cond
 (princ)
) ;_ defun

Posted

That works perfectly, thank you very much Alan. :D

 

I have learned a bit more... (I have plenty to learn)

 

thx for your time.

 

Pascal

Posted
That works perfectly, thank you very much Alan. :D

 

I have learned a bit more... (I have plenty to learn)

 

thx for your time.

 

Pascal

 

You're very welcome. I was curious if I could do it. Learning to code has saved me so much time and headaches.:wink:

  • 4 months later...
Posted

Little better functionality...

 

(defun c:MLTC (/ ss obj int)
 ;; Move Lines to Curve
 ;; Required Subroutines: AT:GetSel
 ;; Alan J. Thompson, 03.16.10 / 08.02.10
 (vl-load-com)
 (if (and (princ "\nSelect line object(s) to move: ")
          (setq ss (ssget "_:L" '((0 . "LINE,LWPOLYLINE"))))
          (AT:GetSel entsel
                     "\nSelect curve to move line(s) to: "
                     (lambda (x)
                       (if (wcmatch (cdr (assoc 0 (entget (car x)))) "ARC,LINE,*POLYLINE,SPLINE")
                         (setq obj (vlax-ename->vla-object (car x)))
                       )
                     )
          )
     )
   ((lambda (id)
      (vlax-for x (setq
                    ss (vla-get-activeselectionset
                         (cond (*AcadDoc*)
                               ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
                         )
                       )
                  )
        (if (and (/= id (vla-get-objectid x))
                 (eq 3 (length (setq int (vlax-invoke x 'IntersectWith obj acExtendThisEntity))))
            )
          (vl-catch-all-apply
            (function vla-move)
            (list x
                  (vlax-3d-point
                    (car (vl-sort (list (vlax-curve-getStartPoint x) (vlax-curve-getEndPoint x))
                                  (function (lambda (a b) (< (distance a int) (distance b int))))
                         )
                    )
                  )
                  (vlax-3d-point int)
            )
          )
        )
      )
      (vla-delete ss)
    )
     (vla-get-objectid obj)
   )
 )
 (princ)
)

(defun AT:GetSel (meth msg fnc / ent good)
 ;; meth - selection method (entsel, nentsel, nentselp)
 ;; msg - message to display (nil for default)
 ;; fnc - optional function to apply to selected object
 ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC")))
 ;; Alan J. Thompson, 05.25.10
 (setvar 'errno 0)
 (while (not good)
   (setq ent (meth (cond (msg)
                         ("\nSelect object: ")
                   )
             )
   )
   (cond
     ((vl-consp ent)
      (setq good (if (or (not fnc) (fnc ent))
                   ent
                   (prompt "\nInvalid object!")
                 )
      )
     )
     ((eq (type ent) 'STR) (setq good ent))
     ((setq good (eq 52 (getvar 'errno))) nil)
     ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again.")))
   )
 )
)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...