(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values " "1st leg Len " 10 9 "6" "2nd leg len" 10 9 "6" "Thickness " 10 9 "1" )))
; Sample chart:
; Original code by Grrr
; Modified by Alanh to do 4 directions
; pt2 pt3
; | |
; | |
; | |
; | | pt4
; | |___________ pt5
; pt1 |________________ pt6
;
;
(defun C:BAA ( / oldsnap pt1 LG1 LG2 THK1 l1 l2 l3 l4 pt1 pt2 pt3 pt4 pt5 pt6) ; always localise your variables
(defun l1 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list THK1 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list THK1 THK1 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 THK1 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6 "c")
)
(defun l2 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list THK1 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list THK1 (- THK1) 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 (- THK1) 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6 "c")
)
(defun l3 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list (- THK1) 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list (- THK1) THK1 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 THK1 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6 "c")
)
(defun l4 ( / )
(setq pt2 (mapcar '+ pt1 (list 0.0 LG1 0.0))) ; calculate the vertical leg by adding 'LG1' distance to 'pt's Y coordinate
(setq pt3 (mapcar '+ pt2 (list (- THK1) 0.0 0.0))) ; calculate the inner top vertex by adding 'THK1' distance on 'ipt_legYaxis' s X coordinate
(setq pt4 (mapcar '+ pt1 (list (- THK1) (- THK1) 0.0))) ; calculate the inner intersection by adding 'THK1' distance on 'pt's X coordinate and Y coordinate
(setq pt6 (mapcar '+ pt1 (list LG2 0.0 0.0))) ; calculate the horizontal leg by adding 'LG2' distance to 'pt's X coordinate
(setq pt5 (mapcar '+ pt6 (list 0.0 (- THK1) 0.0))) ; calculate the inner bottom vertex by adding 'THK1' distance on 'ipt_legXaxis' s Y coordinate
(command "_.pline" pt1 pt2 pt3 pt4 pt5 pt6 "c")
)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(if (= (setq pt1 (getpoint "Choose a starting point")) nil)
(alert "User interrupted an input")
(progn
(setq ans (AH:getvalsm (list "Enter values " "Height " 6 5 "100" "Length " 6 5 "150" "Thick " 6 5 "10" )))
(setq LG1 (atof (nth 0 ans)) lG2 (atof (nth 1 ans)) THK1 (atof (nth 2 ans)))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(cond
((and (> lg1 0.0)(> LG2 0.0))(L1))
((and (< lg1 0.0)(> LG2 0.0))(L2))
((and (> lg1 0.0)(< lg2 0.0))(L3))
((and (< lg1 0.0)(< lg2 0.0))(L4))
) ; cond
(setvar 'osmode oldsnap)
); progn
); if
(princ)
); defun C:BAA
(c:baa)
Is there a good way to make it work without the "Multi GETVALS" LISP?You can always combine the two files by putting al the code from multi getvals.lsp at the end of your lisp file.
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-custom-shape-with-formed-leg/td-p/11281202
; angle design
; Sample chart:
; Original code by Grrr
; Modified by Alanh to do 4 directions July 2022
; pt2 pt3
; | |
; | |
; | |
; | | pt4
; | |___________ pt5
; pt1 |________________ pt6
;
;
(defun C:BAA ( / oldsnap pt1 LG1 LG2 THK1 l1 l2 l3 l4 pt1 pt2 pt3 pt4 pt5 pt6) ; always localise your variables
(defun dtr (a)
(* pi (/ a 180.0))
)
(setq pi90 (/ Pi 2.0) pi270 (* 1.5 pi))
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(if (= (setq pt1 (getpoint "Choose a starting point")) nil)
(alert "User interrupted an input")
(progn
(setq ans (AH:getvalsm (list "Enter values " "Height " 6 5 "100" "ANG1" 6 5 "0" "Length " 6 5 "150" "ANG2" 6 5 "90" "Thick " 6 5 "10" )))
(setq LG1 (atof (nth 0 ans)) ang1 (dtr (atof (nth 1 ans))) lG2 (atof (nth 2 ans)) ang2 (dtr (atof (nth 3 ans))) THK1 (atof (nth 4 ans)))
(setq oldsnap (getvar 'osmode) oldaunits (getvar 'aunits))
(setvar 'osmode 0)
(setvar 'aunits 3)
(setq pt2 (polar pt1 (+ pi90 ang1) lg1))
(setq pt3 (polar pt2 ang1 THK1))
(setq pt4 (polar pt3 (+ pi270 ang1) lg1))
(setq pt6 (polar pt1 (+ pi270 ang2) lg2))
(setq pt5 (polar pt6 ang2 thk1))
(setq pt7 (polar pt5 (- ang2 pi270) lg2))
(command "_.pline" pt4 pt3 pt2 pt1 pt6 pt5 pt7 "")
(setq pt6 (mapcar '* (mapcar '+ pt7 pt5) '(0.5 0.5)))
(setq pt7(mapcar '* (mapcar '+ pt3 pt4) '(0.5 0.5)))
(setvar 'filletrad 0.0)
(command "fillet" pt6 pt7)
(setvar 'osmode oldsnap)
(setvar 'aunits oldaunits)
); progn
); if
(princ)
); defun C:BAA
(c:baa)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(if (= (setq pt1 (getpoint "Choose a starting point")) nil)
(alert "User interrupted an input")
(progn
(setq ans (AH:getvalsm (list "Enter values " "Height " 6 5 "100" "Length " 6 5 "150" "Thick " 6 5 "10" "ANGLE" 6 5 "90")))
(setq LG1 (atof (nth 0 ans)) LG2 (atof (nth 2 ans)) THK1 (atof (nth 4 ans)) ang1 (* pi (/ (atof (nth 3 ans)) 180.0)) )
; simple draw a box and dimension it
; By Alan H March 2019
(defun ah:box ( / pt1 pt2 pt3 ahl ahh ahoff )
(setq oldsnap (getvar 'osmode))
(setq oldang (getvar 'angdir))
(setq pt1 (getpoint "\nPick lower left"))
(setvar 'osmode 0)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Simple rectang" "Enter length" 8 7 "1" "Enter height " 8 7 "2")))
(setq ahL (atof (nth 0 ans)))
(setq ahH (atof (nth 1 ans)))
(setq pt2 (polar pt1 0.0 ahl))
(setq pt3 (polar pt2 (/ pi 2.0) ahH))
(command "rectang" pt1 pt3)
(setq ahoff (* 2.0 (* (getvar 'dimasz)(getvar 'dimscale)))) ; change offset as required
(setq pt4 (polar pt2 (* pi 1.5) ahoff))
(command "dim" "hor" pt1 pt2 pt4 "" "exit")
(setq pt4 (polar pt3 0.0 ahoff))
(command "dim" "Ver" pt2 pt3 pt4 "" "exit")
(setvar 'osmode oldsnap)
)
(ah:box)
(setq pt3 (mapcar '+ pt1 pt2) ) ; adds
(setq pt3 (mapcar '(lambda (x) (/ x 2.0)) pt3) ; divide pt3 by 2
these 2 are same answer
(setq mp (mapcar '* (mapcar '+ p1 p3) '(0.5 0.5))) ; midpoint of 2 points a double add 2 pts then multiply by 0.5
(setq mp (mapcar '/ (mapcar '+ p1 p3) '(2.0 2.0))) ; midpoint of 2 points a double add 2 pts then divide by 2
(setq pt3 (mapcar '+ pt3 (list X Y 0))) ; adds x and y to a point value can be X or Y or Z
(command "dim" "ang" (ssget pt1)(ssget pt2) pt3 "" "" "exit")