2D Flex Lisp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am pretty green when it comes to AutoLisp. I mostly take lisps routines and make modifications when absolutely necessary, however, recently and acquaintance of mine was trying to help me out when I asked if he had anything which would help create flexible ductwork in 2D. He provided a lisp routine which apparently worked in older versions of AutoCAD (2011, etc.), but it no longer works with AutoCAD 2015.
After spending the last week trying to get it to work, I just could not figure out what was happening. If anyone could help me out, I would greatly appreciate it. Any help at all!
(defun c:dflex () (if (null startgroup)(load "makegroup")) (setq DD sf) (initget 1 "Y y N n") (setq DROP (strcase(getkword "\Do you want a DROP at the end of the flex <y/n>: "))) (setq C-PT (getvar "VIEWCTR")) (command "insert" "FlexDuct" C-PT "" "" "") (command "erase" "l" "") (if dd (progn (initget (+ 2 4)) (setq newdd (getdist (strcat "\nEnter size of duct in inches <"(rtos dd)">:"))) (if (= newdd nil) (setq newdd dd) (setq dd newdd))) (progn (initget (+ 1 2 4)) (setq dd (getdist "\nEnter size of duct in inches:")) (setq DD DRW-WDTH FS-PT S-PT) (setq SS2 (ssadd)) (setq(setq fs-pt (getpoint "\nPick start point of flex"))) (setq startpt fs-pt) ;save for later (setq FN-PT (getpoint FS-PT "\n\nPick next point of flex branch: ")) (command "pline" FS-PT FN-PT "") (ssadd (entlast) SS2) (setq PT-SAV FS-PT FS-PT FN-PT FN-PT (getpoint FS-PT "\n\nPick next point of flex branch <or RETURN>:")) ;;setq (while FN-PT (command "pline" FS-PT FN-PT "") (ssadd (entlast) SS2) (setq PT-SAV FS-PT FS-PT FN-PT FN-PT (getpoint FS-PT "\n\nPick next point of flex branch <or RETURN to End>:")) ;;setq) ;;while (setq LST-ANG (angle PT-SAV FS-PT)) (command "pedit" SS2 "j" SS2 "" "s" "") (command "fillet" "r" (* 1.5 dd)) (command "fillet" "p" FS-PT) (setq FLX-LN (entlast)) (startgroup flx-ln) (command "measure" (list flx-ln FS-PT) "b" "FlexDuct" "y" (* 0.25 dd)) (setq SS3 (ssget "P")) (command "erase" FLX-LN "") (setq C 0 SSL (sslength SS3)) ;scale up all the blocks (while (< C SSL)) (setq ENT (entget (ssname SS3 C))) (setq ENT (subst (cons 41 DD) (assoc 41 ENT) ENT)) (setq ENT (subst (cons 42 DD) (assoc 42 ENT) ENT)) (setq ENT (subst (cons 43 DD) (assoc 43 ENT) ENT)) (entmod ENT) (setq C (+ C 1)) (setq en (ssname ss3 0)) ;get first entity (setq enl (entget en)) (setq pt1 (get 10 enl)) ;store insertion point (Command "copy" en "" pt1 startpt) ;copy the item because measure doesn't do the first point (endgroup) ;;while;;; (if (= DROP "Y") ;;; (command "insert" "FlexDrop" FS-PT DD ""(* LST-ANG (/ 360.0 (* PI 2.0)))) (setq OPT-1 "Q") ;;flex
The above is the lisp I received. I tried cleaning it up from what I received, but it looks like I've failed somewhere. I've also attached the two drawing files it requires and an image of what it's supposed to accomplish.
T.I.A.