Author Topic: Frame design lisp tutorial  (Read 10823 times)

0 Members and 1 Guest are viewing this topic.

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #15 on: February 18, 2009, 11:41:30 AM »
What's my point? Spend some time in said help file(s), worth every moment invested. :)
will do.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Frame design lisp tutorial
« Reply #16 on: February 18, 2009, 12:27:51 PM »
This is another way to gather the needed information & a very simple way, simple to me, to create the line work.
Note that this is not how I would do it today but how I learned in my first lisp routines.
It is simply Drawing with LISP, that is using the same commands you would use at the command line
to create the line work.

I'm sure someone will give you an example using entmake instead of command "._line"
Code: [Select]
(defun c:DrawFram (/ 1/2MEMSZ 180DEG 270DEG 90DEG DIMOPT LL LR MEMSZ
                   MPL MPU UL UR WHEIGHT WWIDTH)
    ;;  NOTE: uses current layer
    (if
        (and
            (setq Wheight (getdist "\n Enter window height: "))
            (setq Wwidth (getdist "\n Enter window width: "))
            (setq MemSz (getdist "\n Enter member size of sill: "))
            (or
                (initget "Outer Inner")
                (setq DimOpt
                    (cond
                        ((getkword "\n Dimension are [ Outer/Inner ]<Outer>: "))
                        (t "Outer")
                    )
                )
            )
            (setq LL (getpoint "\n Pick window location for Lower Left Corner."))
        )
        (progn
          (if (= DimOpt "Inner") ; change to outer
            (setq Wheight (+ Wheight MemSz MemSz)
                  Wwidth  (+ Wwidth MemSz MemSz)
            )
          )
          ;; Create angle variables, use 0.0
          (setq 90deg  (/ pi 2.0)
                180deg pi
                270deg (* pi 1.5)
          )
          ;;  get the four outer corner points
          (setq LR (polar LL 0.0 Wwidth ) ; Lower Right
                UL (polar LL 90deg Wheight) ; Upper Left
                UR (list (car LR)(cadr UL)) ; Upper Right
          )
          ;;  Draw the parts
          ;;  Left Frame
          (command "._LINE" "_non" LL "_non" UL "")
          (command "._LINE" "_non" (polar LL 0.0 MemSz) "_non" (polar UL 0.0 MemSz) "")
          (command "._LINE" "_non" LL "_non" (polar LL 0.0 MemSz) "")
          (command "._LINE" "_non" UL "_non" (polar UL 0.0 MemSz) "")
          ;;  Right Frame
          (command "._LINE" "_non" LR "_non" UR "")
          (command "._LINE" "_non" (polar LR 180deg MemSz) "_non" (polar UR 180deg MemSz) "")
          (command "._LINE" "_non" LR "_non" (polar LR 180deg MemSz) "")
          (command "._LINE" "_non" UR "_non" (polar UR 180deg MemSz) "")
          ;;  Middle Vertical Frame
          (setq MPL (polar LL 0.0 (/ Wwidth 2.0)) ; Mid Point Lower
                MPU (polar UL 0.0 (/ Wwidth 2.0))
                1/2MemSz (/ MemSz 2.0)
          )
          (command "._LINE" "_non" (polar MPL 0.0 1/2MemSz) "_non" (polar MPU 0.0 1/2MemSz) "")
          (command "._LINE" "_non" (polar MPL 180deg 1/2MemSz) "_non" (polar MPU 180deg 1/2MemSz) "")
          (command "._LINE" "_non" (polar MPL 180deg 1/2MemSz) "_non" (polar MPL 0.0 1/2MemSz) "")
          (command "._LINE" "_non" (polar MPU 180deg 1/2MemSz) "_non" (polar MPU 0.0 1/2MemSz) "")
          ;;  Upper Left Horz Frame
          (command "._LINE" "_non" (polar UL 0.0 MemSz) "_non" (polar MPU 180deg 1/2MemSz) "")
          (command "._LINE" "_non" (polar (polar UL 0.0 MemSz) 270deg MemSz)
                            "_non" (polar (polar MPU 180deg 1/2MemSz) 270deg MemSz) "")
          ;;  Lower Left Horz Frame
          (command "._LINE" "_non" (polar LL 0.0 MemSz) "_non" (polar MPL 180deg 1/2MemSz) "")
          (command "._LINE" "_non" (polar (polar LL 0.0 MemSz) 90deg MemSz)
                            "_non" (polar (polar MPL 180deg 1/2MemSz) 90deg MemSz) "")
          ;;  Upper Right Horz Frame
          (command "._LINE" "_non" (polar UR 180deg MemSz) "_non" (polar MPU 0.0 1/2MemSz) "")
          (command "._LINE" "_non" (polar (polar UR 180deg MemSz) 270deg MemSz)
                            "_non" (polar (polar MPU 0.0 1/2MemSz) 270deg MemSz) "")
          ;;  Lower Right Horz Frame
          (command "._LINE" "_non" (polar LR 180deg MemSz) "_non" (polar MPL 0.0 1/2MemSz) "")
          (command "._LINE" "_non" (polar (polar LR 180deg MemSz) 90deg MemSz)
                            "_non" (polar (polar MPL 0.0 1/2MemSz) 90deg MemSz) "")
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Frame design lisp tutorial
« Reply #17 on: February 18, 2009, 12:53:53 PM »
Here is another one...

http://204.101.252.14/library/lispdk.html

ELWIND.zip file

; FILE NAME: ELWIND.LSP
; Written by: Bob Thomas               
;             Thomas Enterprises, ltd. 
;             1030 "B" Street, Suite 201
;             San Rafael, CA 94901   
;             415/453-8712
; This file and its accompanying drawing file, ELWIND.DWG, may be freely
; copied provided that the two files remain together and this header remains
; intact, so that people know what the program does and I can get a free
; plug in. Thank you.  Use and enjoy...
;
; ELWIND is a command to create architectural elevation drawings of different
; window types, with a "grilled" option. All variables are local except those
; used to carry defaults, as follows:
;
; w     = default window width
; h     = default window height
; oset1 = default 1st offset
; oset2 = default 2nd offset
; gs    = default grill spacing
;
;
; Command:
; ELWIND - Creates elevation windows
;
; Command Prompt Sequence:
;
;    Awning/Casement/Dblhung/Fixed/Gliding
;         Awning - Hidden lines connecting lower corners with upper midpoint
;         Casement - Hidden lines connecting right corners with left midpoint
;         Dblhung - Standard double-hung window
;         Fixed - Simple non-opening window
;         Gliding - Horizontal sliding window
;
; Select options with either the option word (or the first letter of the
; option word).
;
;    Width:
;    Height:
;    1st offset:
;    2nd offset:
;    Grilled? <N>:
;        Grill spacing:
;
; Respond to prompts with the appropriate value. Refer to accompanying
; AutoCAD drawing file, EL-WN.DWG, for a diagram illustrating the meaning
; of the various options.
;
; Note: In order to save time and node space, if you select the "grilled"
; option, the window grill is drawn onscreen after the window is positioned.
;
; PROGRAM:
;


Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #18 on: February 18, 2009, 01:09:39 PM »
This is another way to gather the needed information & a very simple way, simple to me, to create the line work.
Note that this is not how I would do it today but how I learned in my first lisp routines.
It is simply Drawing with LISP, that is using the same commands you would use at the command line
to create the line work.

I'm sure someone will give you an example using entmake instead of command "._line"

Wow, there is alot in there that I don't understand but it is clearer now than ever...  Drawing lines with lisp using polar entry...
I need to modify it now so that I can draw the pairs of lines seperatly though.  You see, the frames we draw often span entire high rise elevations and have multiple horizontals/verticals.
I need to alter it so that I am able to draw the parallel lines one set at a time.  and then be able to go some distance up from the bottom of a vertical member and draw to parallel lines horizontally (perpendicular).  Then closing the tops and bottoms of the vertical members making them 4 line segments that form a rectangle.
Also, the initget function arguments are limiting me.  The dimensions I have to work with are often mixed between centerlines and "outers".  Meaning one  horizontal continuous dimension may start at the "outer" of the left jamb and the give me a the dimension to the center line of each vertical and then end at the outer of the right Jamb.  I'll Illustrate in a simple dwg.
But this is exaclty what I was hoping for, to be involved in the process of writing so that I retain what went into it.  Thanks everybody.
« Last Edit: February 18, 2009, 04:00:13 PM by CAB »

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #19 on: February 18, 2009, 01:23:47 PM »
Here is another one...

http://204.101.252.14/library/lispdk.html

ELWIND.zip file

Thanks, that is a great site for handy tools i can tell.  Bookmarked for later...
However, that particular lisp file is not much help to me because of the nature and detail of the shop drawings we do.  Also, that lisp seems to be a great tool for drawing residential style casement windows but not much in the way of storefronts and curtain walls.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Frame design lisp tutorial
« Reply #20 on: February 18, 2009, 01:27:03 PM »
The code is just an example but it does draw the exact example found in your Steps.dwg labeled 3.
End caps and all.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #21 on: February 18, 2009, 02:46:42 PM »
The code is just an example but it does draw the exact example found in your Steps.dwg labeled 3.
End caps and all.


Yes thank you!  I will study and dissect in order to further my understanding.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Frame design lisp tutorial
« Reply #22 on: February 18, 2009, 03:50:08 PM »
;;;Curtain wall creater (2D) (c) 97
;;;Original concept by Rob Starz For use with Autocad R13 & R14
;;;Stardsign@aol.com

I have a modified version...but it is not a standalone routine.

This routine I have modified and added a dialog box...if you want it I can send it to you off line, but it will need major modification to make it a standalone routine.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Frame design lisp tutorial
« Reply #23 on: February 18, 2009, 04:04:18 PM »
This example is the same routine using the entmake function which has advantages over the Command "._LINE"
As you will see the entmake is not bothered with osnaps and handles layers more easily.
Code: [Select]
(defun c:DrawFram (/ 1/2MEMSZ 180DEG 270DEG 90DEG DIMOPT LL LR MEMSZ
                   MPL MPU UL UR WHEIGHT WWIDTH
                  )
  (defun MakeLine (st en lay)
    (or lay (setq lay (getvar "clayer")))
    (entmakex
      (list    (cons 0 "LINE")
               (cons 6 "BYLAYER")
               (cons 8 lay)
               (cons 10 st)
               (cons 11 en)
               (cons 39 0.0)
               (cons 62 256)
               (cons 210 (list 0.0 0.0 1.0))))
  )


  ;;  NOTE: uses current layer
  (if
    (and
      (setq Wheight (getdist "\n Enter window height: "))
      (setq Wwidth (getdist "\n Enter window width: "))
      (setq MemSz (getdist "\n Enter member size of sill: "))
      (or
        (initget "Outer Inner")
        (setq DimOpt
               (cond
                 ((getkword "\n Dimension are [ Outer/Inner ]<Outer>: "))
                 (t "Outer")
               )
        )
      )
      (setq LL (getpoint "\n Pick window location for Lower Left Corner."))
    )
     (progn
       (if (= DimOpt "Inner") ; change to outer
         (setq Wheight (+ Wheight MemSz MemSz)
               Wwidth  (+ Wwidth MemSz MemSz)
         )
       )
       ;; Create angle variables, use 0.0
       (setq 90deg  (/ pi 2.0)
             180deg pi
             270deg (* pi 1.5)
       )
       ;;  get the four outer corner points
       (setq LR (polar LL 0.0 Wwidth)     ; Lower Right
             UL (polar LL 90deg Wheight)  ; Upper Left
             UR (list (car LR) (cadr UL)) ; Upper Right
       )
       ;;  Draw the parts
       ;;  Left Frame
       (MakeLine LL UL nil)
       (MakeLine (polar LL 0.0 MemSz) (polar UL 0.0 MemSz) nil)
       (MakeLine LL (polar LL 0.0 MemSz) nil)
       (MakeLine UL (polar UL 0.0 MemSz) nil)
       ;;  Right Frame
       (MakeLine LR UR nil)
       (MakeLine (polar LR 180deg MemSz) (polar UR 180deg MemSz) nil)
       (MakeLine LR (polar LR 180deg MemSz) nil)
       (MakeLine UR (polar UR 180deg MemSz) nil)
       ;;  Middle Vertical Frame
       (setq MPL      (polar LL 0.0 (/ Wwidth 2.0)) ; Mid Point Lower
             MPU      (polar UL 0.0 (/ Wwidth 2.0))
             1/2MemSz (/ MemSz 2.0)
       )
       (MakeLine (polar MPL 0.0 1/2MemSz) (polar MPU 0.0 1/2MemSz) nil)
       (MakeLine (polar MPL 180deg 1/2MemSz) (polar MPU 180deg 1/2MemSz) nil)
       (MakeLine (polar MPL 180deg 1/2MemSz) (polar MPL 0.0 1/2MemSz) nil)
       (MakeLine (polar MPU 180deg 1/2MemSz) (polar MPU 0.0 1/2MemSz) nil)
       ;;  Upper Left Horz Frame
       (MakeLine (polar UL 0.0 MemSz) (polar MPU 180deg 1/2MemSz) nil)
       (MakeLine (polar (polar UL 0.0 MemSz) 270deg MemSz)
                 (polar (polar MPU 180deg 1/2MemSz) 270deg MemSz) nil)
       ;;  Lower Left Horz Frame
       (MakeLine (polar LL 0.0 MemSz) (polar MPL 180deg 1/2MemSz) nil)
       (MakeLine (polar (polar LL 0.0 MemSz) 90deg MemSz)
                 (polar (polar MPL 180deg 1/2MemSz) 90deg MemSz) nil)
       ;;  Upper Right Horz Frame
       (MakeLine (polar UR 180deg MemSz) (polar MPU 0.0 1/2MemSz) nil)
       (MakeLine (polar (polar UR 180deg MemSz) 270deg MemSz)
                 (polar (polar MPU 0.0 1/2MemSz) 270deg MemSz) nil)
       ;;  Lower Right Horz Frame
       (MakeLine (polar LR 180deg MemSz) (polar MPL 0.0 1/2MemSz) nil)
       (MakeLine (polar (polar LR 180deg MemSz) 90deg MemSz)
                 (polar (polar MPL 0.0 1/2MemSz) 90deg MemSz) nil)
     )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #24 on: February 18, 2009, 05:28:33 PM »

This routine I have modified and added a dialog box...if you want it I can send it to you off line, but it will need major modification to make it a standalone routine.

I'd like to experiment with that but I may have to ask your advice for modifying it.  I don't know if I would even know where to start but if you will send it to me I will give my best effort.

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #25 on: February 18, 2009, 05:32:11 PM »
This example is the same routine using the entmake function which has advantages over the Command "._LINE"

Thanks CAB, this will give me a contrast and comparison to the first one which should help me make sense of the process.

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #26 on: February 20, 2009, 05:59:03 PM »
OK so I thought that anyone who has been helping me for the last month or so might be interested in seeing my progress.

Keep in mind I stumbled onto this site just 43 days ago talking about "what is a LISP".

But here is my first attempt to draw curtainwall frame members with lisp.

If anyone cares to comment please do...  What I want to do now is have an "(if" option at the beginning that asks if it is horizontal or vertical...  I would also like for the lines to be in the process of appearing as I pick the point for mullion height.  Anyway, my first lisp..  Take a look.

Code: [Select]
;this lsp will draw curtain wall frame members one at a time vertical or horizontal
;here goes

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

(defun c:myfrm() ;define function

;get face dimension and insertion point of member
(setq sl (getdist "\nSight Line : ")
     ip (getpoint "\nInsertion Point : ")
)

;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

;find points for lines to connect
(setq pt1 (polar ip (dtr 180.0) (/ sl 2)
)
)

(setq mh (getdist "\nMullion Height : ")
)

(setq pt2 (polar pt1 (dtr 90.0) mh)
)

(setq pt3 (polar pt2 (dtr 0.0) sl)
)

(setq pt4 (polar pt3 (dtr 270.0) mh)
)

;Draw lines hopefully
(command "line" pt1 pt2 pt3 pt4 pt1 "")
(princ)
)
(princ)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Frame design lisp tutorial
« Reply #27 on: February 20, 2009, 06:09:49 PM »
Note that the Osmode when ON will cause you trouble if any of your points used within a command are near existing objects.
The snaps can pull the points away from there intended location. As you see in my lisp that used the LINE command, I
used "_non" before each point to insure the osnaps were ignored.
Like this:
Code: [Select]
(command "line" "_non" pt1 "_non" pt2 "_non" pt3 "_non" pt4 "_non" pt1 "")
The alternative is to turn off the osmode while the commands are being executed.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.