Author Topic: to draw centerline in 2 different polyline  (Read 5353 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 291
to draw centerline in 2 different polyline
« on: March 11, 2010, 08:14:34 AM »
hi freind
i am seeking  lisp to draw centerline in 2 different line
can you see attach file

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: to draw centerline in 2 different polyline
« Reply #1 on: March 11, 2010, 08:35:22 AM »
Something like this?

Code: [Select]
(defun c:cPoly (/ ent1 ent2 i len pt p1 ptlst)
  (vl-load-com)

  (if (and (setq ent1 (car (entsel "\nSelect First Polyline: ")))
           (wcmatch (cdr (assoc 0 (entget ent1))) "*POLYLINE")
           (setq ent2 (car (entsel "\nSelect Second Polyline: ")))
           (wcmatch (cdr (assoc 0 (entget ent2))) "*POLYLINE"))
    (progn
      (setq i -1 len (/ (vla-get-Length
                          (vlax-ename->vla-object ent1)) 100.))
     
      (while (setq pt (vlax-curve-getPointatDist ent1 (* (setq i (1+ i)) len)))
        (setq p1    (vlax-curve-getClosestPointto ent2 pt t)
              ptlst (cons (polar pt (angle pt p1) (/ (distance pt p1) 2.)) ptlst)))
     
      (setq ptlst (apply (function append)
                         (mapcar
                           (function
                             (lambda (x) (list (car x) (cadr x)))) ptlst)))
     
      (vla-AddLightWeightPolyline
        (vla-get-ModelSpace
          (vla-get-ActiveDocument (vlax-get-acad-object)))
        (variant
          (vlax-safearray-fill
            (safearray vlax-VBDouble (cons 0 (1- (length ptlst)))) ptlst)))))

  (princ))

A 'fun' one here

dussla

  • Bull Frog
  • Posts: 291
Re: to draw centerline in 2 different polyline
« Reply #2 on: March 13, 2010, 10:35:34 AM »
lee really thank you for good answer always ~
code is good ~

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: to draw centerline in 2 different polyline
« Reply #3 on: March 13, 2010, 10:37:36 AM »
You're welcome Dussla  :-)