Page I. Page II. Home. Page IV.

### The Basics in a Nutshell - Page III.

Well, as you can see, we have quite a few points that we need to calculate.
Fortunately, AutoLisp has a function to help us, the (polar) function.
The (polar) function works like this :

You pass it a point, an angle and a distance and (polar) will return a second point at the specified angle and distance from the first point.

But, we have one problem. All angles in AutoLisp MUST be given in radians.
Let's quickly write a function to do that. Add this function to your Testbeam.lsp file :

(defun dtr (x)

(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI

)	;end of function

O.K. thats our "degrees to radians" function taken care of.
Now we'll have a look at the (polar) function in action.

(setq p2 (polar ip (dtr 180.0) (- (/ lb 2) nl)))
What we are saying here is :

"Set the variable "p2" to a point that, from the insertion point "ip", at an angle of 180.0 degrees (converted to radians), is at a distance of the length of the beam divided by 2, minus the length of the notch."

This will calculate and return the point "p2". Let's do the rest :

(defun c:testbeam ()
;define the function

;********************************************************
;Get User Inputs

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam

(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam

(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange

(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate

(setq nl (getdist "\nLength of Notch : "))
;get the length of notch

(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch

;End of User Inputs
;*********************************************************
;Get Insertion Point

(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point

;********************************************************

;Start of Polar Calculations

(setq p2  (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3  (polar p2 (dtr 270.0) wt))
(setq p4  (polar p2 (dtr 270.0) nd))
(setq p5  (polar p4 (dtr 180.0) nl))
(setq p6  (polar p5 (dtr 180.0) ep))
(setq p7  (polar p6 (dtr 270.0) (- hb nd)))
(setq p8  (polar p7 (dtr 0.0) ep))
(setq p9  (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations

;**********************************************************

(princ)
;finish cleanly

)	;end of defun

;**********************************************************

;This function converts Degrees to Radians.

(defun dtr (x)

(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI

)	;end of function

;**********************************************************
;**********************************************************

Right, now that we've calculated all the points required to draw the beam, let us add a (command) function to do this task for us.
(defun c:testbeam ()
;define the function
;********************************************************

;Get User Inputs

(setq lb (getdist "\nLength of Beam : "))
;get the length of the beam

(setq hb (getdist "\nHeight of Beam : "))
;get the height of the beam

(setq wt (getdist "\nFlange Thickness : "))
;get the thickness of the flange

(setq ep (getdist "\nEnd Plate Thickness : "))
;get the thickness of the end plate

(setq nl (getdist "\nLength of Notch : "))
;get the length of notch

(setq nd (getdist "\nDepth of Notch : "))
;get the depth of the notch

;End of User Inputs
;*********************************************************
;Get Insertion Point

(setq ip (getpoint "\nInsertion Point : "))
;get the insertion point

;********************************************************
;Start of Polar Calculations

(setq p2  (polar ip (dtr 180.0) (- (/ lb 2) nl)))
(setq p3  (polar p2 (dtr 270.0) wt))
(setq p4  (polar p2 (dtr 270.0) nd))
(setq p5  (polar p4 (dtr 180.0) nl))
(setq p6  (polar p5 (dtr 180.0) ep))
(setq p7  (polar p6 (dtr 270.0) (- hb nd)))
(setq p8  (polar p7 (dtr 0.0) ep))
(setq p9  (polar p8 (dtr 90.0) wt))
(setq p10 (polar p9 (dtr 0.0) lb))
(setq p11 (polar p8 (dtr 0.0) lb))
(setq p12 (polar p11 (dtr 0.0) ep))
(setq p13 (polar p12 (dtr 90.0) (- hb nd)))
(setq p14 (polar p13 (dtr 180.0) ep))
(setq p15 (polar p14 (dtr 180.0) nl))
(setq p16 (polar p15 (dtr 90.0) (- nd wt)))
(setq p17 (polar p16 (dtr 90.0) wt))
;End of Polar Calculations
;**********************************************************

;Start of Command Function

(command "Line" ip p2 p4 p6 p7 p12 p13 p15 p17 "c"
"Line" p3 p16 ""
"Line" p9 p10 ""
"Line" p5 p8 ""
"Line" p11 p14 ""
)        ;End Command
;End of Command Function

;*********************************************************
(princ)
;finish cleanly

)	;end of defun

;**********************************************************
;This function converts Degrees to Radians.

(defun dtr (x)

(* pi (/ x 180.0))
;divide the angle by 180 then
;multiply the result by the constant PI

)	;end of function

;**********************************************************