;; SwaMiti Surface Development Tool for Turret with One Square End, Visit www.swamiti.com for more ;;; TURRETDEV1 - cylindrical turret plate development, version 1.0 ;;; Units: mm. Angle: turret axis from vertical, in degrees. ;;; One end square to the axis; the other end is a horizontal plane. ;;; L is measured ALONG THE AXIS between those planes. ;;; Mean diameter = ID + thickness. No weld, kerf or forming allowance. ;;; Run in model space. Output is in WCS XY at the selected point's Z. ;;; Native dimensions are non-associative; rerun after changing inputs. (defun td1:height (dm len ang theta) (- len (* 0.5 dm (/ (sin ang) (cos ang)) (cos theta)))) (defun td1:stations (dm len ang / i result) (setq i 0 result nil) (repeat 19 (setq result (cons (list (/ (* i pi dm) 18.0) (td1:height dm len ang (/ (* i pi) 9.0))) result)) (setq i (1+ i))) (reverse result)) (defun td1:point (base x y) (list (+ (car base) x) (+ (cadr base) y) (caddr base))) (defun td1:make-original (data) (if (not (entmake data)) (progn (prompt "\nCould not create a drawing object.") (exit)))) (defun td1:unique (table root / name index) (setq name root index 0) (while (tblsearch table name) (setq index (1+ index) name (strcat root "-" (itoa index)))) name) ;; A fresh layer for each run, so an existing frozen/locked layer cannot ;; hide the result. Explicit entity properties avoid current-layer effects. (defun td1:layer (root color / name) (setq name (td1:unique "LAYER" root)) (td1:make (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 name) '(70 . 0) (cons 62 color) '(6 . "Continuous"))) name) (defun td1:line (p q layer) (td1:make (list '(0 . "LINE") '(100 . "AcDbEntity") '(67 . 0) '(410 . "Model") (cons 8 layer) '(100 . "AcDbLine") (cons 10 p) (cons 11 q)))) (defun td1:text (p height value rotation layer style) (td1:make (list '(0 . "TEXT") '(100 . "AcDbEntity") '(67 . 0) '(410 . "Model") (cons 8 layer) '(100 . "AcDbText") (cons 10 p) (cons 40 height) (cons 1 value) (cons 50 rotation) (cons 7 style) '(72 . 0) '(100 . "AcDbText") '(73 . 0)))) (defun td1:dim (p q location rotation layer style) (td1:make (list '(0 . "DIMENSION") '(100 . "AcDbEntity") '(67 . 0) '(410 . "Model") (cons 8 layer) '(100 . "AcDbDimension") (cons 10 location) '(70 . 32) '(1 . "<>") (cons 3 style) '(100 . "AcDbAlignedDimension") (cons 13 p) (cons 14 q) (cons 50 rotation) '(100 . "AcDbRotatedDimension")))) (defun td1:draw-main (id thick len degrees base / dm ang amp width pitch ht outline grid dims notes font ds n i x y verts stations row p q top tolerance) (setq dm (+ id thick) ang (/ (* degrees pi) 180.0) amp (* 0.5 dm (/ (sin ang) (cos ang))) width (* pi dm) pitch (/ width 18.0) ht (* pitch 0.055) top (+ len amp) tolerance 0.01) (setq outline (td1:layer "TDEV-OUTLINE" 7) grid (td1:layer "TDEV-STATIONS" 8) dims (td1:layer "TDEV-DIMS" 3) notes (td1:layer "TDEV-NOTES" 2)) (setq font (td1:unique "STYLE" "TDEV-TEXT")) (td1:make (list '(0 . "STYLE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbTextStyleTableRecord") (cons 2 font) '(70 . 0) '(40 . 0.0) '(41 . 1.0) '(50 . 0.0) '(71 . 0) (cons 42 ht) '(3 . "txt.shx") '(4 . ""))) (setq ds (td1:unique "DIMSTYLE" "TDEV-MM")) (td1:make (list '(0 . "DIMSTYLE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbDimStyleTableRecord") (cons 2 ds) '(70 . 0) '(40 . 1.0) (cons 41 (* ht 0.65)) (cons 42 (* ht 0.3)) (cons 44 (* ht 0.5)) (cons 140 ht) '(144 . 1.0) (cons 147 (* ht 0.3)) '(73 . 0) '(74 . 0) '(77 . 1) '(78 . 0) '(170 . 0) '(271 . 2) '(277 . 2) '(278 . 46) '(280 . 0) '(289 . 3) (cons 340 (tblobjname "STYLE" font)))) ;; Linear interpolation error <= amp*(2*pi/n)^2/8. ;; n is a multiple of 18, includes every dimension station, >= 360. (setq n (* 18 (max 20 (1+ (fix (/ (* pi (sqrt (/ amp (* 2.0 tolerance)))) 18.0)))))) ;; Closed outline: bottom-left, bottom-right, top-right, ... top-left. (setq verts nil i 0) (repeat (1+ n) (setq x (/ (* width i) n) y (td1:height dm len ang (/ (* 2.0 pi i) n)) verts (cons (cons 10 (list (+ (car base) x) (+ (cadr base) y))) verts) i (1+ i))) (td1:make (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(67 . 0) '(410 . "Model") (cons 8 outline) '(100 . "AcDbPolyline") (cons 90 (+ n 3)) '(70 . 1) (cons 38 (caddr base)) (cons 10 (list (car base) (cadr base))) (cons 10 (list (+ (car base) width) (cadr base)))) verts)) (setq stations (td1:stations dm len ang) i 0) (foreach row stations (setq x (car row) y (cadr row) p (td1:point base x 0.0) q (td1:point base x y)) (if (and (> i 0) (< i 18)) (td1:line p q grid)) ;; Each height dimension is placed just to the right of its station. (td1:dim p q (td1:point base (+ x (* 0.16 pitch)) (/ y 2.0)) (/ pi 2.0) dims ds) (td1:text (td1:point base (- x ht) (* -2.5 ht)) ht (itoa i) 0.0 notes font) (td1:text (td1:point base (- x ht) (+ y (* 1.5 ht))) ht (strcat (itoa (* i 20)) "d") 0.0 notes font) (if (< i 18) (td1:dim p (td1:point base (+ x pitch) 0.0) (td1:point base x (* -6.0 ht)) 0.0 dims ds)) (setq i (1+ i))) (td1:dim base (td1:point base width 0.0) (td1:point base 0.0 (* -11.0 ht)) 0.0 dims ds) (td1:text (td1:point base 0.0 (+ top (* 11.0 ht))) (* 1.5 ht) "TURRET PLATE DEVELOPMENT - MEAN DIAMETER" 0.0 notes font) (td1:text (td1:point base 0.0 (+ top (* 7.5 ht))) ht (strcat "ID=" (rtos id 2 2) " t=" (rtos thick 2 2) " Dm=" (rtos dm 2 2) " Axis L=" (rtos len 2 2) " Axis inclination=" (rtos degrees 2 2) " deg from vertical") 0.0 notes font) (td1:text (td1:point base 0.0 (+ top (* 4.5 ht))) ht (strcat "18 divisions at 20 deg; pitch=" (rtos pitch 2 2) " mm; height min/max=" (rtos (- len amp) 2 2) "/" (rtos top 2 2) " mm") 0.0 notes font) (td1:text (td1:point base 0.0 (* -15.0 ht)) ht "BOTTOM = SQUARE END | SEAM = STATIONS 0 / 18 (MINIMUM HEIGHT)" 0.0 notes font) (td1:text (td1:point base 0.0 (* -18.0 ht)) ht "All dimensions in mm. No weld/kerf/forming allowance. Curve error <= 0.01 mm." 0.0 notes font) (prompt (strcat "\nDevelopment created. Width=" (rtos width 2 2) "; pitch=" (rtos pitch 2 2) "; minimum height=" (rtos (- len amp) 2 2) ". Use ZOOM Extents to view. One UNDO removes this run."))) (defun td1:input (message default / value) (initget 6) (setq value (getreal (strcat message " <" (rtos default 2 2) ">: "))) (if value value default)) ;; SwaMiti Surface Development Tool for Turret with One Square End, Visit www.swamiti.com for more (defun c:TURRETDEV1 (/ *error* undoOpen id thick len degrees ang amp base valid) (defun *error* (message) (if undoOpen (command-s "_.UNDO" "_End")) (if (and message (not (wcmatch (strcase message) "*CANCEL*,*QUIT*,*EXIT*"))) (prompt (strcat "\nTURRETDEV1: " message))) (if undoOpen (prompt "\nRun UNDO to remove any partial drawing.")) (princ)) (if (= 1 (getvar "CVPORT")) (prompt "\nSwitch to model space before running TURRETDEV1.") (progn (prompt "\nTURRETDEV1: millimetres; inclination of turret axis from vertical.") (setq id (td1:input "\nInternal diameter (mm)" 2000.0) thick (td1:input "\nWall thickness (mm)" 12.0) len (td1:input "\nLength along turret axis (mm)" 1800.0) valid nil) (while (not valid) (initget 4) (setq degrees (getreal "\nAxis inclination from vertical, 0 <= angle < 90 <30>: ")) (if (not degrees) (setq degrees 30.0)) (if (>= degrees 90.0) (prompt "\nAngle must be less than 90 degrees.") (setq valid T))) (setq ang (/ (* degrees pi) 180.0) amp (* 0.5 (+ id thick) (/ (sin ang) (cos ang)))) (if (<= len amp) (prompt (strcat "\nNo drawing: axis length must exceed " (rtos amp 2 4) " mm, otherwise minimum plate height is zero or negative.")) (progn (setq base (getpoint "\nPick bottom-left seam point : ")) (if base (setq base (trans base 1 0)) (setq base '(0.0 0.0 0.0))) (command-s "_.UNDO" "_Begin") (setq undoOpen T) (td1:draw id thick len degrees base) (command-s "_.UNDO" "_End") (setq undoOpen nil))))) (princ)) (princ "\nLoaded TURRETDEV1.lsp. Type TURRETDEV1 to draw. Enter accepts demo values.") (princ) ;; SwaMiti Surface Development Tool for Turret with One Square End, Visit www.swamiti.com for more ;; Embedded vector logo derived from the approved SwaMiti logo asset. ;; Each run is a filled vector strip; no external raster reference is required. (defun td1:logo-cell (p u v w h scale layer / a b c d) (setq a (td1:point p (* u scale) (* v scale)) b (td1:point a (* w scale) 0.0) c (td1:point a 0.0 (* h scale)) d (td1:point b 0.0 (* h scale))) (td1:make (list '(0 . "SOLID") '(100 . "AcDbEntity") '(67 . 0) '(410 . "Model") (cons 8 layer) '(420 . 2957) '(100 . "AcDbTrace") (cons 10 a) (cons 11 b) (cons 12 c) (cons 13 d)))) (defun td1:brand (p ht / layer style scale row) (setq layer (td1:layer "SWAMITI-BRANDING" 7) style (td1:unique "STYLE" "SWAMITI-TEXT") scale (/ (* 6.0 ht) 177.0)) (td1:make (list '(0 . "STYLE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbTextStyleTableRecord") (cons 2 style) '(70 . 0) '(40 . 0.0) '(41 . 1.0) '(50 . 0.0) '(71 . 0) (cons 42 ht) '(3 . "txt.shx") '(4 . ""))) (foreach row '( (27 176 58 1) (113 176 5 1) (23 175 64 1) (112 175 7 1) (20 174 68 1) (111 174 9 1) (18 173 70 1) (111 173 10 1) (17 172 72 1) (110 172 12 1) (15 171 74 1) (110 171 13 1) (14 170 75 1) (110 170 14 1) (13 169 75 1) (111 169 14 1) (13 168 75 1) (111 168 15 1) (12 167 75 1) (112 167 15 1) (11 166 75 1) (113 166 15 1) (11 165 19 1) (50 165 26 1) (114 165 15 1) (11 164 15 1) (51 164 20 1) (115 164 15 1) (11 163 13 1) (51 163 18 1) (116 163 15 1) (12 162 10 1) (51 162 16 1) (117 162 15 1) (12 161 9 1) (50 161 16 1) (118 161 15 1) (13 160 7 1) (49 160 16 1) (119 160 15 1) (15 159 3 1) (48 159 16 1) (120 159 15 1) (47 158 16 1) (120 158 16 1) (46 157 16 1) (121 157 16 1) (45 156 16 1) (122 156 16 1) (45 155 15 1) (122 155 17 1) (44 154 15 1) (123 154 17 1) (43 153 15 1) (123 153 18 1) (42 152 15 1) (123 152 19 1) (41 151 15 1) (123 151 20 1) (40 150 15 1) (124 150 19 1) (39 149 15 1) (123 149 21 1) (38 148 15 1) (123 148 22 1) (37 147 15 1) (123 147 23 1) (36 146 15 1) (123 146 24 1) (35 145 15 1) (123 145 25 1) (34 144 15 1) (123 144 26 1) (33 143 15 1) (123 143 27 1) (32 142 15 1) (122 142 29 1) (31 141 15 1) (122 141 30 1) (30 140 15 1) (121 140 12 1) (138 140 15 1) (29 139 16 1) (120 139 12 1) (139 139 15 1) (28 138 16 1) (120 138 11 1) (140 138 15 1) (27 137 16 1) (119 137 12 1) (141 137 15 1) (26 136 16 1) (118 136 13 1) (142 136 15 1) (25 135 16 1) (117 135 13 1) (143 135 15 1) (24 134 16 1) (117 134 13 1) (144 134 15 1) (23 133 16 1) (116 133 13 1) (144 133 16 1) (22 132 16 1) (115 132 14 1) (145 132 16 1) (21 131 16 1) (114 131 14 1) (146 131 16 1) (21 130 15 1) (113 130 14 1) (147 130 16 1) (20 129 15 1) (111 129 16 1) (148 129 16 1) (19 128 15 1) (110 128 16 1) (149 128 15 1) (18 127 15 1) (109 127 16 1) (150 127 15 1) (17 126 15 1) (108 126 16 1) (151 126 15 1) (16 125 15 1) (107 125 16 1) (152 125 15 1) (15 124 15 1) (106 124 16 1) (153 124 15 1) (14 123 15 1) (105 123 16 1) (154 123 15 1) (13 122 15 1) (103 122 17 1) (155 122 15 1) (12 121 15 1) (102 121 17 1) (156 121 14 1) (11 120 15 1) (101 120 17 1) (157 120 14 1) (11 119 14 1) (100 119 17 1) (158 119 14 1) (10 118 14 1) (99 118 16 1) (159 118 14 1) (9 117 15 1) (98 117 16 1) (159 117 14 1) (9 116 14 1) (96 116 17 1) (160 116 14 1) (8 115 14 1) (95 115 17 1) (161 115 13 1) (7 114 14 1) (94 114 17 1) (162 114 13 1) (7 113 13 1) (93 113 17 1) (162 113 13 1) (6 112 13 1) (92 112 16 1) (163 112 13 1) (6 111 13 1) (91 111 16 1) (164 111 12 1) (5 110 13 1) (90 110 16 1) (164 110 13 1) (5 109 12 1) (89 109 16 1) (165 109 12 1) (4 108 13 1) (88 108 16 1) (165 108 12 1) (4 107 12 1) (87 107 16 1) (166 107 12 1) (4 106 12 1) (86 106 15 1) (166 106 12 1) (3 105 12 1) (86 105 14 1) (166 105 12 1) (3 104 12 1) (85 104 14 1) (167 104 12 1) (3 103 12 1) (85 103 13 1) (167 103 12 1) (2 102 12 1) (84 102 13 1) (167 102 12 1) (2 101 12 1) (84 101 12 1) (168 101 11 1) (2 100 12 1) (83 100 13 1) (168 100 11 1) (1 99 12 1) (83 99 12 1) (168 99 12 1) (1 98 12 1) (83 98 11 1) (168 98 12 1) (1 97 12 1) (82 97 12 1) (168 97 12 1) (1 96 12 1) (82 96 11 1) (168 96 12 1) (1 95 12 1) (82 95 11 1) (169 95 11 1) (1 94 12 1) (82 94 11 1) (169 94 11 1) (0 93 13 1) (82 93 10 1) (169 93 11 1) (0 92 14 1) (81 92 11 1) (169 92 11 1) (0 91 15 1) (81 91 11 1) (169 91 11 1) (0 90 66 1) (81 90 11 1) (169 90 11 1) (0 89 67 1) (81 89 11 1) (169 89 11 1) (0 88 68 1) (81 88 11 1) (169 88 11 1) (0 87 68 1) (81 87 11 1) (169 87 11 1) (0 86 68 1) (81 86 11 1) (168 86 12 1) (0 85 68 1) (82 85 10 1) (168 85 12 1) (0 84 68 1) (82 84 11 1) (168 84 12 1) (0 83 68 1) (82 83 11 1) (168 83 12 1) (0 82 67 1) (82 82 11 1) (168 82 11 1) (0 81 65 1) (82 81 12 1) (168 81 11 1) (0 80 14 1) (82 80 12 1) (167 80 12 1) (0 79 13 1) (83 79 12 1) (167 79 12 1) (1 78 11 1) (83 78 12 1) (167 78 12 1) (1 77 11 1) (84 77 12 1) (167 77 11 1) (1 76 11 1) (84 76 13 1) (166 76 12 1) (1 75 12 1) (84 75 14 1) (166 75 12 1) (1 74 12 1) (85 74 14 1) (165 74 12 1) (1 73 12 1) (86 73 14 1) (165 73 12 1) (2 72 11 1) (86 72 15 1) (165 72 12 1) (2 71 12 1) (87 71 15 1) (164 71 12 1) (2 70 12 1) (88 70 15 1) (164 70 12 1) (2 69 12 1) (88 69 16 1) (163 69 13 1) (3 68 12 1) (89 68 16 1) (163 68 12 1) (3 67 12 1) (90 67 16 1) (162 67 13 1) (3 66 13 1) (91 66 17 1) (161 66 13 1) (4 65 12 1) (92 65 17 1) (161 65 13 1) (4 64 12 1) (93 64 17 1) (160 64 13 1) (4 63 13 1) (94 63 17 1) (159 63 14 1) (5 62 12 1) (95 62 17 1) (159 62 13 1) (5 61 13 1) (97 61 16 1) (158 61 13 1) (6 60 13 1) (98 60 17 1) (157 60 14 1) (6 59 13 1) (99 59 17 1) (156 59 14 1) (7 58 13 1) (100 58 17 1) (155 58 14 1) (7 57 13 1) (101 57 17 1) (154 57 15 1) (8 56 13 1) (102 56 17 1) (154 56 14 1) (8 55 14 1) (103 55 17 1) (153 55 14 1) (9 54 13 1) (105 54 16 1) (152 54 14 1) (10 53 13 1) (106 53 16 1) (151 53 14 1) (10 52 14 1) (107 52 15 1) (150 52 15 1) (11 51 14 1) (108 51 15 1) (149 51 15 1) (12 50 14 1) (109 50 15 1) (148 50 15 1) (12 49 15 1) (110 49 15 1) (148 49 14 1) (13 48 14 1) (111 48 15 1) (147 48 14 1) (14 47 14 1) (113 47 14 1) (146 47 14 1) (15 46 14 1) (114 46 13 1) (145 46 14 1) (15 45 15 1) (115 45 13 1) (144 45 14 1) (16 44 15 1) (116 44 13 1) (143 44 15 1) (17 43 15 1) (117 43 13 1) (142 43 15 1) (18 42 15 1) (118 42 12 1) (141 42 15 1) (19 41 15 1) (119 41 12 1) (141 41 14 1) (20 40 15 1) (120 40 12 1) (140 40 14 1) (21 39 15 1) (121 39 12 1) (138 39 15 1) (22 38 15 1) (122 38 30 1) (22 37 16 1) (122 37 29 1) (23 36 16 1) (123 36 28 1) (24 35 16 1) (124 35 26 1) (25 34 16 1) (124 34 25 1) (26 33 16 1) (125 33 23 1) (27 32 15 1) (125 32 22 1) (28 31 15 1) (126 31 20 1) (29 30 15 1) (126 30 19 1) (30 29 15 1) (126 29 18 1) (31 28 15 1) (126 28 17 1) (32 27 15 1) (126 27 17 1) (33 26 15 1) (126 26 16 1) (34 25 15 1) (125 25 16 1) (35 24 15 1) (125 24 15 1) (36 23 15 1) (124 23 15 1) (37 22 15 1) (124 22 14 1) (38 21 15 1) (123 21 14 1) (38 20 16 1) (122 20 14 1) (39 19 16 1) (121 19 15 1) (40 18 16 1) (120 18 15 1) (41 17 16 1) (119 17 15 1) (42 16 16 1) (118 16 15 1) (43 15 17 1) (117 15 15 1) (44 14 17 1) (116 14 16 1) (45 13 18 1) (115 13 16 1) (46 12 20 1) (114 12 17 1) (153 12 2 1) (47 11 22 1) (113 11 19 1) (148 11 9 1) (48 10 32 1) (112 10 46 1) (49 9 32 1) (111 9 48 1) (51 8 31 1) (111 8 48 1) (52 7 31 1) (111 7 48 1) (54 6 29 1) (111 6 48 1) (55 5 28 1) (111 5 48 1) (57 4 26 1) (111 4 47 1) (60 3 23 1) (112 3 45 1) (62 2 20 1) (112 2 43 1) (65 1 16 1) (114 1 37 1) (70 0 10 1) (117 0 27 1)) (td1:logo-cell p (car row) (cadr row) (caddr row) (nth 3 row) scale layer)) (td1:text (td1:point p (+ (* 180.0 scale) (* 2.0 ht)) (* 2.0 ht)) ht "Prepared with SwaMiti Tool, Visit www.swamiti.com for more" 0.0 layer style)) ;; SwaMiti Surface Development Tool for Turret with One Square End, Visit www.swamiti.com for more ;; Collect extents from objects created by this run only. Dynamic locals belong ;; to the draw wrapper, so old objects and the current drawing extents are ignored. (defun td1:make (data / pair p kind height) (setq kind (cdr (assoc 0 data))) (if (member kind '("LINE" "LWPOLYLINE" "TEXT" "DIMENSION" "SOLID")) (progn (foreach pair data (if (and (member (car pair) '(10 11 12 13 14)) (listp (cdr pair))) (progn (setq p (cdr pair)) (if (and (numberp (car p)) (numberp (cadr p))) (setq swaMinX (if swaMinX (min swaMinX (car p)) (car p)) swaMinY (if swaMinY (min swaMinY (cadr p)) (cadr p))))))) (if (= kind "TEXT") (progn (setq height (cdr (assoc 40 data))) (if (and height (> height 0.0)) (setq swaTextH (if swaTextH (min swaTextH height) height))))))) (td1:make-original data)) (defun td1:draw (id thick len degrees base / swaMinX swaMinY swaTextH) (td1:draw-main id thick len degrees base) (if (and swaMinX swaMinY swaTextH) (td1:brand (list swaMinX (- swaMinY (* 14.0 swaTextH)) 0.0) swaTextH)))