amarendra Posted June 5, 2019 Posted June 5, 2019 Hello Dear Friends, how to do the automatically offset in between two lines offset centerline for all. kindly find the attached for sample image with drawing. if anyone knows lisp please help me. I am using AutoCAD 2017 Thanks Amarendra HVAC sample Offset.dwg Quote
ammobake Posted June 5, 2019 Posted June 5, 2019 So you are wanting to offset towards the center to automatically create a centerline between two parallel lines (with the spacing varying it looks like). Correct? I worked in HVAC industry for a few months in my first CAD job in 2004. BUT most of the time we used CADduct add-on software for AutoCAD (just at the time it was extremely overpriced). I'm not sure if it's still available but it was pretty handy especially for large projects like hospitals and stuff. The software would automatically draw the ductwork in 3D with the necessary gauging of material and sizes to meet ANSI/SMACNA specs. It would also calc your flows if I remember correctly. It basically lets you "build" the ductwork as you go along using an interface that had various dropdown menus for adding different types/shapes of duct as you went. At the time, the concept of BIM was still not really a thing with AutoCAD Architecture being the closest equivalent. So it was pretty advanced for the time. The add-on would also produce part lists and export all the DXF shape files for each duct member/section so you could put your plasma cutter to work. The guys in the metal shop did the rest. ChriS Quote
BIGAL Posted June 6, 2019 Posted June 6, 2019 The only tricky part is the arcs the rest is just set snap mid, so if you snap mid and its an arc ask for second arc, then draw arc, rad1+rad2 divide 2. and so on. But like Ammobake just draw correct in 1st place. The code may exist already. Quote
Temy Posted December 25, 2019 Posted December 25, 2019 On 6/5/2019 at 3:54 PM, amarendra said: Hello Dear Friends, how to do the automatically offset in between two lines offset centerline for all. kindly find the attached for sample image with drawing. if anyone knows lisp please help me. I am using AutoCAD 2017 Thanks Amarendra HVAC sample Offset.dwg 168 kB · 1 download Try it to see if it works!!! ; Draw (LW)Polyline between two selected curves (at midpoint of vertices). (defun c:LBL (/ foo AT:GetSel _pnts _pline _lwpline _dist e1 e2) (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) (while (progn (setvar 'ERRNO 0) (setq ent (meth (cond (msg) ("\nSelect object: ")))) (cond ((eq (getvar 'ERRNO) 7) (princ "\nMissed, try again.")) ((eq (type (car ent)) 'ENAME) (if (and fnc (not (fnc ent))) (princ "\nInvalid object!")))))) ent) (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.) (70 . 8))) (foreach x lst (entmakex (list '(0 . "VERTEX") (cons 10 x) '(70 . 32))))) (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)) Quote
tombu Posted December 25, 2019 Posted December 25, 2019 This is what I use: http://www.cadtutor.net/forum/showthread.php?83644-Centerline-between-two-polylines Quote
BIGAL Posted December 25, 2019 Posted December 25, 2019 Go to the download section and have a look at the tzframpton duct program. Quote
SLW210 Posted December 30, 2019 Posted December 30, 2019 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum, please post in the appropriate forum. 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.