;;; capacitor_bracket.LSP ;;; This program will draw a 3D capacitor bracket ;;; copyright 2008 by Charles Robbins (alert "capacitor_bracket.LSP - copyright 2008 by Charles Robbins. Type cap_brkt to start") ;;; start the program (defun c:cap_brkt (/) ;;; drawing setup (setq osm (getvar "osmode")) ; gets osnap settings and assigns them to osm (setvar "osmode" 0) ; turns osnap settings off ;;; setup layers (command "layer" "n" "capacitor_bracket" "c" "white" "capacitor_bracket" "") ; create border layer ;;; user input (setq sp (list 0 0 0)) (alert "Material Thickness Selection Chart \n \n3 ga - 0.2391 \n4 ga - 0.2242 \n5 ga - 0.2092 \n6 ga - 0.1943 \n7 ga - 0.1793 \n8 ga - 0.1644 \n9 ga - 0.1495 \n10 ga - 0.1345 \n11 ga - 0.1196 \n12 ga - 0.1046 \n13 ga - 0.0897 \n14 ga - 0.0747 \n15 ga - 0.0673 \n16 ga - 0.0598 \n17 ga - 0.0538 \n18 ga - 0.0478 \n19 ga - 0.0418 \n20 ga - 0.0359") (initget 1 "3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20") (setq ga (getkword "\nWhat gauge sheet metal do you wish to use? [3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] ")) (setq hgt (getreal "\nWhat is the capacitor bracket height? ")) (setq wdt (getreal "\nWhat is the capacitor bracket width? ")) (setq dpt (getreal "\nWhat is the capacitor bracket depth? ")) (setq r1 (getreal "\nWhat is radius 1? ")) (setq r2 (getreal "\nWhat is radius 2? ")) (setq dia (getreal "\nWhat is diameter of the mounting hole? ")) ;;; do the math (if (= ga "3")(setq ga 0.2391)) (if (= ga "4")(setq ga 0.2242)) (if (= ga "5")(setq ga 0.2092)) (if (= ga "6")(setq ga 0.1943)) (if (= ga "7")(setq ga 0.1793)) (if (= ga "8")(setq ga 0.1644)) (if (= ga "9")(setq ga 0.1495)) (if (= ga "10")(setq ga 0.1345)) (if (= ga "11")(setq ga 0.1196)) (if (= ga "12")(setq ga 0.1046)) (if (= ga "13")(setq ga 0.0897)) (if (= ga "14")(setq ga 0.0747)) (if (= ga "15")(setq ga 0.0673)) (if (= ga "16")(setq ga 0.0598)) (if (= ga "17")(setq ga 0.0538)) (if (= ga "18")(setq ga 0.0478)) (if (= ga "19")(setq ga 0.0418)) (if (= ga "20")(setq ga 0.0359)) (setq x1 (car sp) x4 (+ x1 dpt) x3 (- x4 ga) x2 (- x3 r1) x5 (+ x4 r2 r2) x6 (+ x5 ga) ) (setq y1 (cadr sp) y2 (+ y1 ga) y3 (+ y2 r1) y4 (+ y1 (- hgt r2 ga)) ) ;;; point assignment (setq p1 (list x1 y1) p2 (list x2 y1) p3 (list x4 y3) p4 (list x4 y4) p5 (list x5 y4) p6 (list x6 y4) p7 (list x3 y4) p8 (list x3 y3) p9 (list x2 y2) p10 (list x1 y2) ) ;;; lets draw (command "layer" "s" "capacitor_bracket" "") ; set layer to border (command "pline" p9 p10 p1 p2 "a" p3 "L" p4 "a" p5 "L" p6 "") (command "zoom" "e") (setq ss1 (ssget "L")) (command "pline" p7 p8 "a" p9 "") (command "zoom" "e") (setq ss2 (ssget "L")) (command "arc" p6 "e" p7 "r" (+ ga r2)) ;;; convert to 3D (command "zoom" "e") (setq ss3 (ssget "L")) (command "pedit" ss3 "y" "j" ss1 ss2 "" "") (command "zoom" "e") (setq ss4 (ssget "L")) (command "extrude" ss4 "" wdt) (command "view" "sw") (setq ss5 (ssget "L")) (command "rotate3d" ss5 "" "0,0,0" "1,0,0" "90") (command "cylinder" (list dia (- 0.0 (/ wdt 2.0)) 0) "d" dia ga) (setq ss6 (ssget "L")) (command "subtract" ss5 "" ss6 "") ;;; end of the main program (command "layer" "s" "0" "") ; set layer to 0 (setvar "osmode" osm) ; turns osnap settings back on )