SteveMouchel Posted June 28, 2010 Posted June 28, 2010 Hi guys, I am working on a road scheme and I need to create a centre line between the two edges of the central reserve/median. I have two 3d Polylines of equal lengths and with the same number of vertices. Does anyone know if this is possible in AutoCAD...? I’ve searched for a script but can’t find anything. Any help would be much appreciated and would certainly save me from digitising the entire centre line… this is one section of a 100km scheme. Regards Steve Quote
alanjt Posted June 28, 2010 Posted June 28, 2010 Just step through each vertex for each polyline and draw polyline at the midpoint of the two coinciding vertices. eg. (quickie) Quote
MSasu Posted June 28, 2010 Posted June 28, 2010 Also may use the "secret" M2P Osnap mode that will allow to locate the middle between two points - available in AutoCAD 2010. Regards, Quote
alanjt Posted June 28, 2010 Posted June 28, 2010 Also may use the "secret" M2P Osnap mode that will allow to locate the middle between two points - available in AutoCAD 2010. Regards, It was around long before 2010. Also can be called with MTP. Quote
SteveMouchel Posted June 28, 2010 Author Posted June 28, 2010 Just step through each vertex for each polyline and draw polyline at the midpoint of the two coinciding vertices. eg. (quickie) [ATTACH]21283[/ATTACH] This looks perfect but I can't test it until I'm back in work tomorrow. What command are you using...? Also, does it work using 3d Polylines...? Quote
alanjt Posted June 28, 2010 Posted June 28, 2010 This looks perfect but I can't test it until I'm back in work tomorrow. What command are you using...? Also, does it work using 3d Polylines...? Something I quickly coded out. Yes, it works on LW, 3D and 2D polylines. Quote
MSasu Posted June 28, 2010 Posted June 28, 2010 @alanjt: I'm afraid that the code is missing on post #2. Regards, Quote
SteveMouchel Posted June 29, 2010 Author Posted June 29, 2010 Also may use the "secret" M2P Osnap mode that will allow to locate the middle between two points - available in AutoCAD 2010. Regards, This is great, I never knew it was there. Unfortunately I don't fancy doing this along a line with 25,000 points Quote
JHammond Posted August 17, 2010 Posted August 17, 2010 I would be curious to see the code for this as well... Quote
alanjt Posted August 18, 2010 Posted August 18, 2010 I would be curious to see the code for this as well... I'll post it when I get to work, tomorrow. Quote
alanjt Posted August 18, 2010 Posted August 18, 2010 I was pretty slammed today and completely forgot about it. However, since I met all my deadlines today, I'll have plenty of time to play tomorrow and I'll post it first thing. :wink: Quote
JHammond Posted September 7, 2010 Posted September 7, 2010 I was pretty slammed today and completely forgot about it. However, since I met all my deadlines today, I'll have plenty of time to play tomorrow and I'll post it first thing. :wink: Hi Alan, I was drawing my ramp lines again today and thought I would check to see if the lisp routine you made was posted yet. I hate to be a pest, but could you post it when you get a chance? Thanks. Quote
Guest balajibth84 Posted September 29, 2010 Posted September 29, 2010 Here no lisp attached for Centre Line creation between two Polylines..How can we create with any single command..Any lisp for this???? Quote
ReMark Posted September 29, 2010 Posted September 29, 2010 Yes, there are lisp routines that will draw a centerline and create a line offset to either side. Quote
Guest balajibth84 Posted September 29, 2010 Posted September 29, 2010 Here no lisp attached for Centre Line creation between two Polylines..How can we create with any single command..Any lisp for this????But u r given reply..here lisp is availble...where here its attached??????? Quote
alanjt Posted September 29, 2010 Posted September 29, 2010 (edited) (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) ) Edited September 30, 2010 by alanjt Quote
Guest balajibth84 Posted September 29, 2010 Posted September 29, 2010 Hai alanjt,I am tried this Code in cad 2007..After lbl command its asking Select first open curve:..After i am selecting means this common geeting exit(Nothing reaction).....Can you check it ones??????please Quote
alanjt Posted September 30, 2010 Posted September 30, 2010 Hai alanjt,I am tried this Code in cad 2007..After lbl command its asking Select first open curve:..After i am selecting means this common geeting exit(Nothing reaction).....Can you check it ones??????please I don't understand what you are saying. It works perfectly fine on my end (tested in 08 and 09). Post an example drawing of what you are trying to select. Quote
Guest balajibth84 Posted September 30, 2010 Posted September 30, 2010 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..........Fortest.dwg Quote
Recommended Posts
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.