Well, I took another couple shots at this and I have to say that I still have no clue how the angles work in this code. I only assume I made a greater power angry at some point and now they are laughing.
With this code I can at least make a shape that resembles an angle piece.
(defun C:LBA
( / pt1 LG1 LG2 THK1 pt2 pt3 pt4 pt5 p5A pt6 pt7 p7A pt8 pt9
) ; -Localizes the variables.
(setq CL
(getvar "clayer")) ; -Gets the current layer.
(command "layer" "m" "0" "c" 4 "" "l" "continuous" "" nil) ; -Creates and sets layer 0.
(setq lm
(getvar "limcheck")) ; -Gets the current limit setting.
(setvar "limcheck" 0) ; -Sets limits to 0 or off.
(setq pt1
(getpoint "Please choose a start?")) ; -Bottom left starting point of leg.
(setq LG1
(getdist "Please enter the 1st leg length?")) ; -Vertical leg length.
(setq LG2
(getdist "Please enter the 2nd leg length?")) ; -Horizontal leg length.
(setq THK1
(getdist "How thick is the member?")) ; -Thickness of the angle member.
(setq ang1
(getangle "Set the angle please...")) ; -Sets the angle.
); Closes and
(progn ; -Code block that processes the inputs
(setq pt2
(polar pt1
(/ pi
2) LG1
) ; -Inside of Vertical Leg
pt3
(polar pt2 pi LG2
) ; -Inside of Angled Leg
pt4
(polar pt3
(/ pi
2) THK1
) ; -Thickness of Angled Leg
pt5
(polar pt4
0 (+ LG2 LG1
)) ; -Outside of Angled Leg
pt6
(polar pt1
0 THK1
) ; -Outside of Angled Leg
pt7
(polar pt6
(/ pi
2) (+ LG2 LG1
)) ; -Outside of Angled Leg
pt8
(polar pt1 pi
2) ; -Point for Vert Dim
pt9
(polar pt1
(* pi
1.5) 2) ; -Point for Horz Dim -Side note. I am hoping to make this align with the angled leg.
;(setq p5A (mapcar '* (mapcar '+ pt4 pt5) '(0.5 0.5))) ; -Not working, set to the side for now.
;(setq p7A (mapcar '* (mapcar '+ pt6 pt7) '(0.5 0.5))) ; -Not working, set to the side for now.
); Closes setq
(command "pline" pt7 pt6 pt1 pt2 pt3 pt4 pt5
"") ; -Polyline to make the angle.
(setvar 'filletrad
(THK1
)) ; -Sets the fillet radius.
;(command "fillet" p5A p7A) ; -Creates radius at external corner
); -Closes progn
); -Closes if
(command "dim" "hor" pt2 pt3 pt9
"" "exit") ; -Creates the Angled Leg Dim.
(command "dim" "ver" pt1 pt2 pt8
"" "exit") ; -Creates the Vertical Leg Dim.
(command "layer" "s" cl
"") ; -To set layer back to original.
(setvar "limcheck" lm
) ; -To reset limit to starting limit.
); -Closes defun
When I try to do anything to change the angle is where things to weird and stop being consistent. I have tested a number of different combinations of just angles, radians, angles and radians, rolling dice, etc. but there doesn't seem to be a consistent change when the angle is changed.
The following is an example.
(defun C:LBA
( / pt1 LG1 LG2 THK1 pt2 pt3 pt4 pt5 p5A pt6 pt7 p7A pt8 pt9
) ; -Localizes the variables.
(setq CL
(getvar "clayer")) ; -Gets the current layer.
(command "layer" "m" "0" "c" 4 "" "l" "continuous" "" nil) ; -Creates and sets layer 0.
(setq lm
(getvar "limcheck")) ; -Gets the current limit setting.
(setvar "limcheck" 0) ; -Sets limits to 0 or off.
(setq pt1
(getpoint "Please choose a start?")) ; -Bottom left starting point of leg.
(setq LG1
(getdist "Please enter the 1st leg length?")) ; -Vertical leg length.
(setq LG2
(getdist "Please enter the 2nd leg length?")) ; -Horizontal leg length.
(setq THK1
(getdist "How thick is the member?")) ; -Thickness of the angle member.
(setq ang1
(getangle "Set the angle please...")) ; -Sets the angle.
); Closes and
(progn ; -Code block that processes the inputs
(setq pt2
(polar pt1
(/ pi
2) LG1
) ; -Inside of Vertical Leg
pt3
(polar pt2
(* pi
(/ (- 270 ang1
) 180)) LG2
) ; -Inside of Angled Leg
pt4
(polar pt3
(* pi
(/ (- 180 ang1
) 180)) THK1
) ; -Thickness of Angled Leg
pt5
(polar pt4
(* pi
(/ (- 90 ang1
) 180)) (* LG2
2)) ; -Outside of Angled Leg
pt6
(polar pt1
0 THK1
) ; -Outside of Angled Leg
pt7
(polar pt6
(/ pi
2) (* LG1
2)) ; -Outside of Angled Leg
pt8
(polar pt1 pi
2) ; -Point for Vert Dim
pt9
(polar pt1
(* pi
1.5) 2) ; -Point for Horz Dim -Side note. I am hoping to make this align with the angled leg.
;(setq p5A (mapcar '* (mapcar '+ pt4 pt5) '(0.5 0.5))) ; -Not working, set to the side for now
;(setq p7A (mapcar '* (mapcar '+ pt6 pt7) '(0.5 0.5))) ; -Not working, set to the side for now
); Closes setq
(command "pline" pt7 pt6 pt1 pt2 pt3 pt4 pt5
"") ; -Polyline to make the angle.
(setvar 'filletrad
(THK1
)) ; -Sets the fillet radius.
;(command "fillet" p5A p7A) ; -Creates radius at external corner
); -Closes progn
); -Closes if
;(command "dim" "hor" pt2 pt3 pt9 "" "exit") ; -Creates the Angled Leg Dim.
(command "dim" "ver" pt1 pt2 pt8
"" "exit") ; -Creates the Vertical Leg Dim.
(command "layer" "s" cl
"") ; -To set layer back to original.
(setvar "limcheck" lm
) ; -To reset limit to starting limit.
); -Closes defun
If anyone would point me in a good direction for what I did wrong or how to appease the angry spirits I would greatly appreciate it.
Also, on a side note I decided to change how I create this lisp. I am trying to work it so the 1st leg is always vertical and the 2nd leg rotates around it. I was going to break that into left "LBA" and right "RBA" so the user could pick the side, put in the angle from the vertical and the other dimension. I figured if I did it this way the dimensions provided would always be the inside of the bend. (That's just how the company I work for does things.)