Jump to content

Centre Line between two Polylines


Recommended Posts

Posted
Hai here i have attached my dwg fortesting.....Actuall i am selecting two means its automatically need to take center point and offset that line..........[ATTACH]23380[/ATTACH]

Works fine on my end. What exactly is it doing? Copy everything that is returned to the command line and paste it here.

 

eg.

Command: lbl

Select first open curve:
Select next open curve:
Specify line to draw: [Lwpolyline/Polyline] <Lwpolyline>:

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    11

  • JHammond

    5

  • SteveMouchel

    3

  • MSasu

    2

Top Posters In This Topic

Posted Images

Posted
Hai here i have attached my dwg fortesting.....Actuall i am selecting two means its automatically need to take center point and offset that line..........[ATTACH]23380[/ATTACH]

 

Hi, I just opened your drawing and tested the routine. It seems to be working fine to me. Here is a screen capture of what I am doing:

Forest.gif

In case it is blurry, I entered LBL on the command line, then selected the top line, then the bottom line. After that I did a regen on the screen. Is this somehow not doing what you expect?

Posted
Hi, I just opened your drawing and tested the routine. It seems to be working fine to me. Here is a screen capture of what I am doing:

In case it is blurry, I entered LBL on the command line, then selected the top line, then the bottom line. After that I did a regen on the screen. Is this somehow not doing what you expect?

So, does this give you what you were wanting?

Posted

Yeah, its exactly what I was after. It seemed to me that balajibth84 was having problems with the routine. My little video was just showing it working.

Posted
Yeah, its exactly what I was after. It seemed to me that balajibth84 was having problems with the routine. My little video was just showing it working.

You're welcome.

Posted
(defun c:LBL (/ foo AT:GetSel _pnts _pline _lwpline _dist e1 e2)
 ;; Draw (LW)Polyline between two selected curves (at midpoint of vertices).
 ;; Alan J. Thompson, 09.29.10

 (vl-load-com)

 (defun foo (e)
   (and (wcmatch (cdr (assoc 0 (entget (car e)))) "LINE,*POLYLINE,SPLINE")
        (not (vlax-curve-isClosed (car e)))
   )
 )

 (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 (cond ((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.")))
     )
   )
 )

 (defun _pnts (e / p l)
   (if e
     (cond ((wcmatch (cdr (assoc 0 (entget e))) "ARC,LINE,SPLINE")
            (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e))
           )
           ((wcmatch (cdr (assoc 0 (entget e))) "*POLYLINE")
            (repeat (setq p (1+ (fix (vlax-curve-getEndParam e))))
              (setq l (cons (vlax-curve-getPointAtParam e (setq p (1- p))) l))
            )
           )
     )
   )
 )

 (defun _pline (lst)
   (if (and (> (length lst) 1)
            (entmakex '((0 . "POLYLINE") (10 0 0 0)))
            (foreach x lst (entmakex (list '(0 . "VERTEX") (cons 10 x))))
       )
     (cdr (assoc 330 (entget (entmakex '((0 . "SEQEND"))))))
   )
 )

 (defun _lwpline (lst)
   (if (> (length lst) 1)
     (entmakex (append
                 (list '(0 . "LWPOLYLINE")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbPolyline")
                       (cons 90 (length lst))
                       (cons 70 (* (getvar 'plinegen) 128))
                 )
                 (mapcar (function (lambda (p) (list 10 (car p) (cadr p)))) lst)
               )
     )
   )
 )

 (defun _dist (a b) (distance (list (car a) (cadr a)) (list (car b) (cadr b))))

 (if
   (and
     (setq e1 (_pnts (car (AT:GetSel entsel "\nSelect first open curve: " foo))))
     (setq e2 (_pnts (car (AT:GetSel entsel "\nSelect next open curve: " foo))))
     (not (initget 0 "Lwpolyline Polyline"))
     (setq *LBL:Opt* (cond ((getkword (strcat "\nSpecify line to draw: [Lwpolyline/Polyline] <"
                                              (cond (*LBL:Opt*)
                                                    ((setq *LBL:Opt* "Lwpolyline"))
                                              )
                                              ">: "
                                      )
                            )
                           )
                           (*LBL:Opt*)
                     )
     )
   )
    ((if (eq *LBL:Opt* "Lwpolyline")
       _lwpline
       _pline
     )
      (vl-remove nil
                 (mapcar (function (lambda (a b)
                                     (if (and a b (not (grdraw (trans a 0 1) (trans b 0 1) 1 1)))
                                       (mapcar (function (lambda (a b) (/ (+ a b) 2.))) a b)
                                     )
                                   )
                         )
                         e1
                         (if (< (_dist (car e1) (car e2))
                                (_dist (car e1) (last e2))
                             )
                           e2
                           (reverse e2)
                         )
                 )
      )
    )
 )
 (princ)
)

 

What do I do with the code posted to create the new command? I created a new command in the CUI and pasted this code as the macro, but it didn't work.

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...