Author Topic: Brick Jack Arch Routine  (Read 6698 times)

0 Members and 1 Guest are viewing this topic.

Artisan

  • Guest
Brick Jack Arch Routine
« on: October 28, 2004, 12:48:45 PM »
I would like to put together some sort of routine that would allow me to easily figure and draw brick arches for residential homes. Right now, I figure out my numbers by hand and then enter the results in the array command. It's kind of hard to understand, but I'll try to explain the process out and then let you know what I would like to do. I have attached a jpeg showing what I do:

http://www.theswamp.org/screens/Artisan/JACK.JPG

After I complete all of the steps, I perform the array command enter the numbers in that I have gotten in the equations. I then select the "array line" as shown in the jpeg and use the "arch center" as my array center point and finish the command. Sometimes I have to enter my "angle to fill" number in as a negative to get it to work right.

I was trying to put together a routine that allowed me to select the "array line" and then work out the math and array the line all in one step. I know what numbers and equations to use as shown, I just don't really know where to start when it comes to coming up with a routine. Any advice or help would be appreciated.

Thanks

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Brick Jack Arch Routine
« Reply #1 on: October 28, 2004, 02:33:28 PM »
« Last Edit: March 20, 2006, 01:51:32 PM by CAB »
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Brick Jack Arch Routine
« Reply #2 on: October 28, 2004, 02:56:08 PM »
OK, here is a revised version that uses 3.5" gap at the outer radius.
Code: [Select]
;;;===============================================================
;;;                 Spokes.lsp
;;;               Charles Alan Butler
;;;             ab2draft@TampaBay.rr.com
;;;               03/11/2004 Ver alpha
;;;               Rev 1.0 10/26/2004 3.5" brick
;;;
;;;    Routine to create line segments in a radial pattern
;;;        by picking the center and two circles
;;;================================================================
;;;
;;;   ARGUMENTS NONE
;;;
(defun c:spokes (/  arcsin   p1    p2     p3      ps
pe  fill   r1    r2     lnstart  lnend
ang  angoff   circ    usrosmode
linesegment   arclength
)
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                          
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun arcsin (z /)
    (atan z (sqrt (- 1.0 (* z z))))
  )
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (defun linesegment ()
    (command ".line" lnstart lnend "") ; line segment
    (setq ang  (+ ang angoff) ; next angle
 lnstart (polar p1 ang r1) ; next line pt
 lnend  (polar p1 ang r2) ; next line pt
    )
  )
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (defun arclength (/ 1sta 2nda arl rang)
    ;;Calculates 1st ANGLE
    (setq 1sta (angle p1 (polar p1 (angle p1 ps) r2)))
    ;;Calculates 2nd ANGLE
    (setq 2nda (angle p1 (polar p1 (angle p1 pe) r2)))

    (if (< 1sta 2nda)
      (progn (setq rang (- 2nda 1sta)) ;ANGLE IN RADIANS
    (setq arl (* r2 rang)) ;ARC LENGTH
      ) ;_ end of progn
      (progn (setq rang (+ (* 2 pi) (- 2nda 1sta))) ;ANGLE IN RADIANS
    (setq arl (* r2 rang)) ;ARC LENGTH
      ) ;_ end of progn
    ) ;_ end of IF
  )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                            
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (initget "Arc Circle")
  (if
    (setq fill (getkword "\nFull circle or Arc only [Circle/Arc]<C>"))
     (if (= fill "Arc")
       (progn
(prompt "\nPoints are picked in a counter clock wise rotation.")
(setq
  ps (getpoint "\nPick start point on right end of the arc.")
)
(setq pe (getpoint "\nPick end point on left end of the arc."))
       ) ; end progn
     ) ; endif
     (setq fill "Circle")
  ) ; endif
  (if (and (setq p1 (getpoint "\nPick the center point of the circle or arc."))
           (setq p2 (getpoint "\nPick a point on the inner circle."))
           (setq p3 (getpoint "\nPick a point on the outer circle.")))
(progn
 (setq wd      3.5  ;  width of gap at outer radius
                up (* pi 0.5) ; 90 deg
r1 (distance p1 p2) ; inner radius
r2 (distance p1 p3) ; outer radius
lnstart (polar p1 up r1) ; line pt
lnend (polar p1 up r2) ; line pt
ang up
angoff (* 2 (arcsin (/ (/ wd 2) r2))) ; offset angle
circ (* pi (* r2 2)) ; circumference
 )
 (if (or (= fill "Circle") (and (= fill "Arc") ps pe))
   (progn
     (command ".undo" "begin")
     (setq usrosmode (getvar "osmode"))
     (setvar "osmode" 0)
     (if (= fill "Circle")
(repeat (1+ (fix (/ circ wd)))
 (linesegment)
) ; end repeat
(progn
 (setq numofseg (/ (fix (/ (arclength) wd)) 2)
lnstart (polar p1 ang r1) ; line pt
lnend (polar p1 ang r2) ; line pt
 )
 (repeat (1+ numofseg)
   (linesegment)
 )
 (setq ang up
lnstart (polar p1 ang r1) ; line pt
lnend (polar p1 ang r2) ; line pt
 )
 (repeat numofseg
   (setq ang  (- ang angoff) ; next angle
 lnstart (polar p1 ang r1) ; next line pt
 lnend  (polar p1 ang r2) ; next line pt
   )
   (command ".line" lnstart lnend "") ; line segment
 )
)
     ) ; endif
     (setvar "osmode" usrosmode)
     (command ".undo" "end")
   ) ; end progn
   (alert "\nError. No Arc points.")
 ) ; endif
) ; end progn
  ) ; endif
  (princ)
) ; end defun
(prompt "\nSpokes.lsp loaded, enter spokes to run.")
(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.

Artisan

  • Guest
Brick Jack Arch Routine
« Reply #3 on: October 28, 2004, 03:08:31 PM »
Thanks for the help, CAB. The routine works great, I just wish I knew what all of that code means. I would like to be able to write that stuff for myself one day. I guess I can wish for now though. Thanks again.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Brick Jack Arch Routine
« Reply #4 on: October 28, 2004, 03:42:54 PM »
You are welcome,
If you are serious about learning lisp I'm sure Mark and some others will
help you get started. Perhaps some of the threads about learning lisp are
still too advanced. Perhaps starting with how to construct a basic function
and use the command to draw some geometry. You will learn quickly once
you get a few basics behind you.
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.

dubb

  • Swamp Rat
  • Posts: 1105
Brick Jack Arch Routine
« Reply #5 on: October 28, 2004, 06:02:50 PM »
its too bad there isnt a user group for lisps i would certainly pay for that. because its easier for me to learn in person...I ve read tutorials from afra-lisp like 5 times...yet i still can only contain 1/3 of the information. all i do is copy and paste the code.

Artisan

  • Guest
Brick Jack Arch Routine
« Reply #6 on: October 29, 2004, 07:38:20 AM »
I would be very interested in a forum here that was for beginners. I know that may seem like a hassle, but it sure would help some of us who are not as advanced as some you guys. I have purchased a couple of text to start reading in hopes of getting to the point where I can write my own lisp routines. I have picked up Sham Tickoo's Customizing AutoCad 2000,  Maximizing AutoCad R13 (suggested by someone here) and I am planning on getting Sham's newest release on Customizing AutoCad 2002. Anymore ideas? Am I on the right track? Thanks for the help.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Brick Jack Arch Routine
« Reply #7 on: October 29, 2004, 07:57:29 AM »
Quote from: dubb
its too bad there isnt a user group for lisps i would certainly pay for that. because its easier for me to learn in person...I ve read tutorials from afra-lisp like 5 times...yet i still can only contain 1/3 of the information. all i do is copy and paste the code.

I did too in the beginning. Then I decided to actually type it all out instead, made a BIG difference. FWIW, for me programming is something I have to do all the time or I forget it. Not the basic principles per say but the functions and syntax.
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Brick Jack Arch Routine
« Reply #8 on: October 29, 2004, 08:05:29 AM »
Quote from: Artisan
Am I on the right track?

Yes you are. :D

I'm not sure this place could handle another autolisp forum, but there's no reason not to ask questions in, or help from this forum. If you don't understand something, minor or not, don't hesitate to ask, no ones going to laugh or flame you in here, well they won't do it twice I can assure you that. This is indeed the reason I spend so much time and money on this place.

ask away man. :D
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
Brick Jack Arch Routine
« Reply #9 on: October 29, 2004, 08:10:20 AM »
Quote
...FWIW, for me programming is something I have to do all the time or I forget it. Not the basic principles per say but the functions and syntax.

Me too.

I think the way most of us learned was by asking questions about things we needed. Keep them simple to start. Don't try to get too involved in asking for things that help you keep your standards. This way you can get your feet wet and begin to understand how and when to use things like getpoint, setq, repeat, while - even command work. This way you get a feel for these before you take the next step.

Artisan

  • Guest
Brick Jack Arch Routine
« Reply #10 on: October 29, 2004, 08:25:40 AM »
Thanks Mark. This place is a great resource for everyone.

Columbia

  • Guest
Brick Jack Arch Routine
« Reply #11 on: October 29, 2004, 10:26:29 AM »
The only way to learn how to program is to program.  That may sound a little daunting, but someone can tell you all day long how to do, but until you start typing out the code (like Mark did) and look for the right functions on your own, then you'll never figure it out (unless you're incredibly gifted).

I would hazard a guess as to say that every one of the gurus as well as many of the simple hackers on this forum, learned how to program in AutoLISP by doing it for themselves mostly.  I know we've all asked questions on how to do things, hell we still do, but we all started from the same place you are.  Square one.

The advantage that I see that you and many of the new LISPers out there have, is that you guys/gals can come to the Swamp and ask away.  This place is the best and most supportive group of coding individuals that I've ever run across.  There is no limit to the generosity of these coders.  They give source code, time and advice as if it all were just lying around on the ground just waiting to be picked up.

So ask your questions, don't be surprised when we give code, don't be surprised if we DON'T give code, but instead do our best to prompt you in the right direction.   But when you ask, just give us the most info you can.  That'll help you to ask the right question, as well as give us the chance to actually understand the question you're asking (some of us, namely me, can be pretty dense sometimes).

So, in closing this incredibly long diatribe, let me say welcome to the wonderful (and often frustrating) world of Auto/Visual LISP programming.  :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Brick Jack Arch Routine
« Reply #12 on: October 29, 2004, 10:38:04 AM »
Well put   :)

And
Here is a good start. http://theswamp.org/phpBB2/viewtopic.php?t=137
You need to be comfortable using the VLIDE editor as it is great for
debugging and stepping through code.
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Brick Jack Arch Routine
« Reply #13 on: October 29, 2004, 05:05:48 PM »
If you haven't read Stig's introduction to AutoLisp you can find it here
http://www.smadsen.com/
Look to the left and click on Primer.
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.