; ISOITEMS.LSP v1.0 [04/20/90] ;------------------------------------------------------------------------------ ; WhoDunnit ; ~~~~~~~~~ Originally ISOBOX.LSP ; Revised by: Programmed by: ; Stan H. Bimson Shawn Kondas ; CAD/Engineering Services Albion, In. ; 1038 Forest Harbor Drive ; Hendersonville, TN 37075-9646 USA ; ; Voice: (615)824-4938 ; BBS: (615)353-3476 12/2400 8N1 24hrs - EET BBS, Nashville, TN ; CompuServe: 73507,3475 in the ADESK forum of course! ; and on the GREAT! ; Alacrity BBS: (206)643-LISP -- Where all the Truly Cool AutoDudes hang out. ; ; Notice ; ~~~~~~ ; These programs are being placed in the public domain by Stan Bimson and ; CAD/Engineering Services. The author cannot be held liable for any ; damages incurred as a result of using ISOITEMS.LSP v1.0 ; ; Comments ; ~~~~~~~~ ; Shawn Kondas had two nice little isometric routines: ; ISOBOX for drawing an iso box and ; ISOSIDE for drawing a single iso plane. ; I have just tried to enhanced the code for these two routines and add ; more user enhancements. My BOX routine came out a little more clear ; and clean (that is to me) while my SIDE got a little more complicated ; with it's user enhancements. But the fun was in doing it and does show ; uses of (lambda ..., (mapcar '(lambda ... and (apply '(lambda .... ; ; This Lisp information form is in the general form as described in the ; file STANDARD.LSP and written by Jason Osgood, SysGod of Alacrity BBS. ;------------------------------------------------------------------------------ ; Functions ; ~~~~~~~~~ ; DTOR - degrees to radian conversion, a general AutoLisp function ; ISOBOX - draws a box in 2D isometric. ; ISOSIDE - draws 1 of the 3 sides of a box in 2D isometric depending ; on what isometric plane is currently set. User may change ; plane at prompt. ; ; Global Symbols ; ~~~~~~~~~~~~~~ ; hth - plane height of side ; ls - length of left side plane ; rs - length of right side plane ; ; Revisions ; ~~~~~~~~~ ; 04/20/90 - Stan H. Bimson - released ; ; ?> Works as described. ; !> No known bugs. ; ;------------------------------------------------------------------------------ ; Function ; ~~~~~~~~ ; ISOBOX.LSP v1.1 [04/20/90] ; ; Draws a three sided box in 2D isometric. Current isometric plane has ; no bearing on box. User is prompted for ; 1) the lower point of box, ; the lowest intersection of the right and left sides. ; If the user enters a point the program continues else it stops. ; For the next 3 prompts there are default values that can be used. ; 2) the height of the box, ; the length of the box along the 90 degree edge. ; 3) the length of the left side, the side at 150 degrees. ; 4) the length of the right side, the side at 30 degrees. ; ; Syntax/Arguments ; ~~~~~~~~~~~~~~~~ ; isobox2 entered at AutoCAD's command prompt or ; (c:isobox2) if called from another program. ; ; Example Usage ; ~~~~~~~~~~~~~ ; See description above ; ; Returned Value ; ~~~~~~~~~~~~~~ ; *NONE* ; ;------------------------------------------------------------------------------ (defun C:ISOBOX (/ bm isp0 isp1 isp2 isp3 tl tt tr) (if (null hth) (setq hth 1)) ; first time thru set these global (if (null ls) (setq ls 1)) ; variables to (1) which can be (if (null rs) (setq rs 1)) ; used as a default value (setq bm (getvar "blipmode")) ; ------- Loop while user picks a starting point (while (setq isp0 (getpoint "\nPick lower corner: ")) (setvar "blipmode" 0) (mapcar ; -------------- 3 stage menu '(lambda (pmpt defval / new) (initget (+ 2 4)) ; no 0 or negatives are allowed (setq new (getdist isp0 (strcat pmpt " <" (rtos (eval defval)) ">: "))) (cond ((not (null new)) (set defval new)))); set it if we have a new one ; ------ menu prompts '("\nEnter height" "\nEnter left side" "\nEnter right side") ; ------ menu items to get value for '(hth ls rs) ); end mapcar (command ; ---------- draw the box ".LINE" isp0 (setq isp1 (polar isp0 (dtor 150) ls)) (setq tl (polar isp1 (dtor 90) hth)) (setq tt (polar isp0 (dtor 90) hth)) isp0 (setq isp3 (polar isp0 (dtor 30) rs)) (setq tr (polar isp3 (dtor 90) hth)) tt "" ".LINE" tl (polar tl (dtor 30) rs) tr "") (setvar "blipmode" bm) ); end while (princ) ); end ISOBOX ;------------------------------------------------------------------------------ ; Function ; ~~~~~~~~ ; ISOSIDE.LSP v1.1 [04/20/90] ; ; Draws a single isometric side in the current isometric plane. ; User is prompted for ; 1) ; a) the lower point of side. For the top side the point would be ; the intersection of the low right edge and the low left edge; ; for the left side the point would be the intersection of the ; low left edge and right side vertical; for the right side the ; point would be the intersection of the low right edge and left ; side vertical. ; the lowest intersection of the right and left sides. ; b) user may select to change the current isometric plane by entering ; L/T/R for left, top or right sides. ; c) If the user enters a point the program continues else it stops. ; For the next 2 prompts there are default values that can be used. ; 2) The user is prompted for dimensions of the side to be drawn based ; on current plane setting. For the Left side user is asked for the ; left side and the vertical height; for the Top user is asked for ; the left side and the right side; for the Right user is asked for ; the right side and the vertical height. ; ; Syntax/Arguments ; ~~~~~~~~~~~~~~~~ ; isoside entered at AutoCAD's command prompt or ; (c:isoside) if called from another program. ; ; Example Usage ; ~~~~~~~~~~~~~ ; See description above ; ; Returned Value ; ~~~~~~~~~~~~~~ ; *NONE* ; ; Comments ; ~~~~~~~~ ; Shawn used grdraw to highlight the 4 lines drawn for the side. I surmised ; that this highlighting was to show the user what had just been drawn so ; the user could erase any overlapping lines in the event the user was ; building an isometric figure by adding a side at a time. I have also ; included this feature except I chose to get the entities and use the Lisp ; (redraw ) function to highlight. ;------------------------------------------------------------------------------ (defun C:ISOSIDE (/ isp0 ison bm anglst pmtlst dimlst dlst elast entlst) (if (null hth) (setq hth 1)) ; -- first time thru set these global (if (null ls) (setq ls 1)) ; -- variables to (1) which can be (if (null rs) (setq rs 1)) ; -- used as a default value (while ((lambda (/ done) ; -- input function for ISOSIDE (setq done ()) ; -- setup while loop (while (not done) (setq ison (getvar "snapisopair")) (princ ; -- tell user the current plane (strcat "\nCurrent isoplane: " (cond ((= ison 0) "Left") ((= ison 1) "Top") ((= ison 2) "Right")))) (initget (+ 2 4) "L T R") ; -- get start point or get new isoplane (setq isp0 (getpoint "\nSet plane/L/T/R/or pick lower corner: ")) (cond ((eq (type isp0) 'STR) ; -- do we have a new plane? (setvar "snapisopair" ; -- if so, then change to new plane (cond ((= isp0 "L") 0) ((= isp0 "T") 1) ((= isp0 "R") 2)))) (T (setq done T))) ; -- else user did point or wants to quit ) isp0) ; -- return value from lambda ) ; while condition (cond ; -- setup list depending on current plane ((= ison 0) ; -- left side (setq anglst (list 150 90) pmtlst (list "\nEnter left side" "\nEnter height") dimlst (list 'ls 'hth))) ((= ison 1) ; -- top (setq anglst (list 150 30) pmtlst (list "\nEnter left side" "\nEnter right side") dimlst (list 'ls 'rs))) ((= ison 2) ; -- right side (setq anglst (list 30 90) pmtlst (list "\nEnter right side" "\nEnter height") dimlst (list 'rs 'hth)))) (setq bm (getvar "blipmode")) (setvar "blipmode" 0) (setq dlst ; -- get side dims from user (mapcar ; -- 2 stage menu '(lambda (pmpt defval / new) (initget (+ 2 4)) (setq new (getdist isp0 (strcat pmpt " <" (rtos (eval defval)) ">: "))) (cond ; -- handle user input ((not (null new)) (set defval new)) (T (eval defval))) ) ; -- end lambda pmtlst dimlst) ; -- end mapcar ) (setq elast (entlast) entlst ()) ; -- init for highlighting code (apply ; -- draw the side '(lambda (a1 a2 d1 d2 / lastpt) (command ".LINE" isp0 (setq lastpt (polar isp0 (dtor a1) d1)) (setq lastpt (polar lastpt (dtor a2) d2)) (polar lastpt (dtor (- a1 180)) d1) "c")) (append anglst dlst) ; -- combine the two list ) ; -- end apply (if (null elast) ; -- this is required ONLY if no entities exist in dwg (setq elast (entnext) entlst (cons elast entlst))) ; -- get all entities drawn so we can highlight them for user (while (setq elast (entnext elast)) (setq entlst (cons elast entlst))) (foreach ent entlst (redraw ent 3)) (setvar "blipmode" bm) ) ; -- end while (princ) ) ; -- end ISOSIDE ;------------------------------------------------------------------------------ ; Function ; ~~~~~~~~ ; DTOR v1.0 [09/07/85] ; ; A function to convert degrees to radians. ; ; Syntax/Arguments ; ~~~~~~~~~~~~~~~~ ; (dtor d) where d is an angle value expressed in degrees ; ; Example Usage (syntax) ; ~~~~~~~~~~~~~~~~~~~~~~ ; (dtor 99) convert 99 degrees to it's radian value ; (dtor ang) convert the value of the symbol ang to radians ; ; Returned Value ; ~~~~~~~~~~~~~~ ; angle value expressed in pi radians. ; ;------------------------------------------------------------------------------ (defun dtor (d) (/ (* d pi) 180)) ;---< End Of File >---