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

0 Members and 1 Guest are viewing this topic.

JCUTRONA

  • Guest
Frame design lisp tutorial
« on: February 17, 2009, 04:53:27 PM »
I would love to have a lisp that automates the process illustrated below in steps 1,2 and 3.

I, however, am just getting my feet wet with lisp; learning all about syntax and "car"s and "cdr"s and strings and variables with Jeff Sanders and the fine folks at Afralisp.

I am seeing much progress and am still as eager and motivated as ever.  (MY wife teased me this weekend because on our road trip I had taken printouts of lisp functions to memorize on the road instead of any material from my college classes.)

What would be great is if some one (or someone-s), would give me a tutorial on how to write the perfect lisp for my needs (ie point me in the right direction and help me keep moving along the way by giving clues or direction).  That way, even if it takes a while, not only will I get the lisp i need, but it will also be the best kind of learning experience for me.

SO>>>
What I need this "perfect lisp" to do is basically automate my storefront/curtainwall drawing process. Usually (as in step one), I will draw lines the proper height and distance apart according to centerlines ect given to me on the architectural prints.

>>>Then depending on what dimensions I was given I will either offset one way or the other to give the vertical or horizontal it's thickness.

>>>  Last I clean up, stretching and trimming and extending as necessary.

Ideally, the lisp would first ask me to define whether the material would be 1-3/4" or 2" or 2-1/4" or 2-1/2" thickness.  Then this routine would ask me for a "getpoint" at which time I would pick the centerpoint for the top or bottom or left or right side of the member to be drawn.  At some point I would have to select an option from vertical or horizontal...  I would also have to "pull" the line in the right direction and then give it a direct distance entry.

Essentially this is very similar to the way the line command already works.  It just draws two parallel lines at equal distances from the point you picked.

I also included and example (eg) drawing to show what the finished product is actually made up of.

Any help is greatly appreciated,,, As is this site in general and the pioneers there of!

This is what I got so far
Code: [Select]
(defun C:DRAFRM()
(EDIT) I obviously can't get the png to look right so included said dwg file as well.
« Last Edit: February 17, 2009, 05:08:43 PM by JCutrona »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Frame design lisp tutorial
« Reply #1 on: February 17, 2009, 05:20:36 PM »
Here is how I would start.

Code: [Select]
(defun c:DrawFram ()
   
    (if
        (and
            (setq StPt (getpoint "\n Select first point ( corner of window ): "))
            (setq EndPt (getcorner StPt "\n Select next point: "))
            (setq MemSz (getdist "\n Enter member size of sill: "))
            (or
                (initget "Center Outer Inner")
                (setq DimOpt
                    (cond
                        ((getkword "\n Dimension type [ Center/Outer/Inner ]<Outer>: "))
                        (t "Outer")
                    )
                )
            )
        )
        (progn
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Frame design lisp tutorial
« Reply #2 on: February 17, 2009, 05:25:52 PM »
Your drawing file provided much more information than the picture ever could.

Are you working in metric or imperial units?
If Imperial is you base unit Inches or Feet?

Usually the most tedious part of programing is the user interface.
You will need from the user the material thickness, height & width of the store front
and the reference point to place the objects drawn.

Because the is a simple lines & rectangle the POLAR function is easy to understand and
simple to use when creating lines.

More to follow if Tim doesn't continue. :)
I have to go out for the evening.
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.

Spike Wilbury

  • Guest
Re: Frame design lisp tutorial
« Reply #3 on: February 17, 2009, 05:27:52 PM »
i don't use lisp anymore, but have you tried/option to use dynamic blocks?

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #4 on: February 17, 2009, 05:29:16 PM »
I see that we are setting variables for start point, end points and member sizes.  Cool...
But what does the " (if " and the " (and " start?  Is it a loop of some sort???
And how will picking points at corners play in?

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #5 on: February 17, 2009, 05:32:44 PM »
i don't use lisp anymore, but have you tried/option to use dynamic blocks?
My understanding of dynamic blocks would not be sufficient for this task simply because of how complicated these frames often get.  The ones in the examples are simple for illustration but more often than not the frames span several floors and have multiple intermediate horizontals/verticals.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Frame design lisp tutorial
« Reply #6 on: February 17, 2009, 05:34:16 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.
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 #7 on: February 17, 2009, 05:38:06 PM »
Your drawing file provided much more information than the picture ever could.
Good I will keep this in mind.


Are you working in metric or imperial units?
If Imperial is you base unit Inches or Feet?
Always in inches.  Makes it easier on the guys in the shop to fabricate.


Usually the most tedious part of programing is the user interface.
You will need from the user the material thickness, height & width of the store front
and the reference point to place the objects drawn.

Because the is a simple lines & rectangle the POLAR function is easy to understand and
simple to use when creating lines.
Interesting.  I hope you will explain further.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Frame design lisp tutorial
« Reply #8 on: February 17, 2009, 05:43:16 PM »
I see that we are setting variables for start point, end points and member sizes.  Cool...
But what does the " (if " and the " (and " start?  Is it a loop of some sort???
And how will picking points at corners play in?

The ' if ' is there so that the routine will not run unless it meets what is in the argument section of the ' if ' call.  In this case, the ' and ' call is the argument section of the ' if ' statement.  This is saying that ' if ' you pick a start point ( StPt ) ' and ' a corner point ( EndPt ) ' and ' you enter a member size ( MemSz ) ' and ' you select a dimension option ( DimOpt ), then you can proceed with the routine.  If all options are not entered, then the program will not execute anything.  Hope that makes sense.

The ' or ' option within the ' and ' option is just a preferred way to write that section.  That is because ' initget ' always returns nil, so if used with ' or ' it will always be called, and the second option will always be called, which in this case sets the DimOpt variable.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #9 on: February 17, 2009, 05:47:19 PM »
The ' if ' is there so that the routine will not run unless it meets what is in the argument section of the ' if ' call.  In this case, the ' and ' call is the argument section of the ' if ' statement.  This is saying that ' if ' you pick a start point ( StPt ) ' and ' a corner point ( EndPt ) ' and ' you enter a member size ( MemSz ) ' and ' you select a dimension option ( DimOpt ), then you can proceed with the routine.  If all options are not entered, then the program will not execute anything.  Hope that makes sense.

The ' or ' option within the ' and ' option is just a preferred way to write that section.  That is because ' initget ' always returns nil, so if used with ' or ' it will always be called, and the second option will always be called, which in this case sets the DimOpt variable.
Ok yes that helps.  Thanks..

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #10 on: February 18, 2009, 10:52:59 AM »
"initget"? what is this functions definition?  how is it being used get the "DimOpt"?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Frame design lisp tutorial
« Reply #11 on: February 18, 2009, 11:00:16 AM »
It's being used in conjunction with the getkword function. See the help. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JCUTRONA

  • Guest
Re: Frame design lisp tutorial
« Reply #12 on: February 18, 2009, 11:15:25 AM »
pauses for user to answer the initget question.  I see.

Just knowing the lisp functions are defined in the help is crucial.  Thanks!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Frame design lisp tutorial
« Reply #13 on: February 18, 2009, 11:25:00 AM »
My pleasure. Once upon a time, before Windows, before widely available IDEs and the like, I typed the entire LISP Reference into a text file to use with my then shareware editor PC-Write. It took me 3 days to do it but gave me an excellent fast track overview of the language to the point I barely needed the very help file I created. What's my point? Spend some time in said help file(s), worth every moment invested. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

dustinthiesse

  • Guest
Re: Frame design lisp tutorial
« Reply #14 on: February 18, 2009, 11:28:11 AM »
pauses for user to answer the initget question.  I see.

Initget initializes a "get....." function by restricting the acceptable input in some manner.  In this case, it sets up the options for the getkword function by restricting string input to the defined words OR the capitalized letters within those words (actually it will also work with partial words as well...i.e. "cent" or "out").

No user input is actually done until the getkword function is called.

Ex. Initget can also be used to disallow zero or negative numbers when using getint.