Jump to content

I beam with autolisp


Muhammad Khalid

Recommended Posts

hi everyone just joined in and was wondering if any one with a good knowledge of lisp can go through the routine below which by the way is to generate an I beam with inputs from user and is not working. It does accept the inputs but nothing is drawn in the model space when i run it. Ill be much appreciative thanks in advance.

 

Note the part highlighted red mmmmm not really sure about. Any by thway the icon is not part of the routine

 

Routine start from here

 

(defun c:ukc ()

 

;define the function

 

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

 

;Save System Variables

 

(setq oldsnap (getvar "osmode"))

;save snap settings

 

(setq oldblipmode (getvar "blipmode"))

;save blipmode setting

 

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

;Switch OFF System Variables

 

(setvar "osmode" 0)

;Switch OFF snap

 

(setvar "blipmode" 0)

;Switch OFF Blipmode

 

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

 

;Get User Inputs

 

(initget (+ 1 2 3))

;check user input

 

(setq wl (getdist "\nLength of Web : "))

;get the length of the Length of Web

 

(initget (+ 1 2 3))

;check user input

 

(setq fl (getdist "\nLength of Flange : "))

;get the Length of Flange

 

(initget (+ 1 2 3))

;check user input

 

(setq wt (getdist "\nWeb Thickness : "))

;get the thickness of the Web

 

(initget (+ 1 2 3))

;check user input

 

(setq ft (getdist "\nFlange Thickness : "))

;get the Flange Thickness

 

(initget (+ 1 2 3))

;check user input

 

(setq rr (getdist "\nRoot radius : "))

;get the Root radius

 

(initget (+ 1 2 3))

;check user input

 

(setq nd (getdist "\nDepth of Section : "))

;get the depth of the Section

 

;End of User Inputs

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

;Get Insertion Point

 

(setvar "osmode" 32)

;switch ON snap

 

(while

;start of while loop

 

(setq ip (getpoint "\nInsertion Point : "))

;get the insertion point

 

(setvar "osmode" 0)

;switch OFF snap

 

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

;Start of Polar Calculations

 

(setq p2 (polar ip (dtr 90.0)(/ nd 2)))

(setq p3 (polar p2 (dtr 180.0)(/ fl 2)))

(setq p4 (polar p3 (dtr 270.0) ft))

(setq p5 (polar p4 (dtr 0.0) (-(-(/fl 2)(/wt 2)) rr)))

(setq p56 (polar p5 (dtr 270.0) rr))

(setq p6 (polar p56 (dtr 0.0) rr))

(setq p7 (polar p6 (dtr 270.0) wl))

(setq p78 (polar p7 (dtr 180.0) rr))

(setq p8 (polar p78 (dtr 270.0) rr))

(setq p9 (polar p8 (dtr 180) rr))

(setq p10 (polar p9 (dtr 270) ft))

(setq p11 (polar p10 (dtr 0.0) fl))

(setq p12 (polar p11 (dtr 90) ft))

(setq p13 (polar p12 (dtr 180.0) (-(-(/fl 2)(/wt 2)) rr)))

(setq p1314 (polar p13 (dtr 90) rr))

(setq p14 (polar p1314 (dtr 180.0) rr))

(setq p15 (polar p14 (dtr 90.0) wl))

(setq p1516 (polar p15 (dtr 0.0) rr))

(setq p16 (polar p1516 (dtr 90.0) rr))

(setq p17 (polar p16 (dtr 0.0)(-(-(/fl 2)(/wt 2)) rr)))

(setq p18 (polar p17 (dtr 90.0) ft))

 

;End of Polar Calculations

 

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

 

;Start of Command Function

 

(command "Line" p2 p3 p4 p5 "c"

"Line" p6 p7 ""

"Line" p8 p9 p10 p11 p12 p13 ""

"Line" p14 p15 ""

"Line" p16 p17 p18 p2 ""

;) "arc" p56 p6 p5 ""

"arc" p78 p8 p7 ""

"arc" p1314 p14 p13 ""

"arc" p1516 p16 p15 ""

 

) ;End Command

;End of Command Function

 

 

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

 

(setvar "osmode" 32)

;Switch ON snap

 

);end of while loop

 

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

 

;Reset System Variable

 

(setvar "osmode" oldsnap)

;Reset snap

 

(setvar "blipmode" oldblipmode)

;Reset blipmode

 

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

 

(princ)

;finish cleanly

 

) ;end of defun

 

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

 

;This function converts Degrees to Radians.

 

(defun dtr (x)

;define degrees to radians function

 

(* pi (/ x 180.0))

;divide the angle by 180 then

;multiply the result by the constant PI

 

) ;end of function

 

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

(princ) ;load cleanly

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

Link to comment
Share on other sites

I'm assuming you are doing this to teach yourself lisp with the secondary reason (maybe?) of creating something you would use in your line of work. Yes/No?

Link to comment
Share on other sites

...and is not working...

Replace green with red.

 


[color=yellowgreen](setq p5 (polar p4 (dtr 0.0) (-(-(/fl 2)(/wt 2)) rr)))[/color]
[color=red](setq p5 (polar p4 (dtr 0.0) (-(-(/ fl 2)(/ wt 2)) rr)))[/color]
. 
[color=yellowgreen](setq p13 (polar p12 (dtr 180.0) (-(-(/fl 2)(/wt 2)) rr)))[/color]
[color=red](setq p13 (polar p12 (dtr 180.0) (-(-(/ fl 2)(/ wt 2)) rr)))[/color]
. 
[color=yellowgreen](setq p17 (polar p16 (dtr 0.0)(-(-(/fl 2)(/wt 2)) rr)))[/color]
[color=red](setq p17 (polar p16 (dtr 0.0)(-(-(/ fl 2)(/ wt 2)) rr)))[/color]

 

:)

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...