Code Red > AutoLISP (Vanilla / Visual)

Adding to this lisp?

(1/5) > >>

vinnyg:
Hi everyone,

I wrote this lisp and it needs additional code to finish it correctly (the way I need it)

It draws a pier cap with reinforcing. The problem is when you run it, it's missing 2 items.
There are 2 horizontal bars, 1 at the top and 1 at the bottom. I'm trying to figure out what
lines to add so that the routine places 2 other horiz. bars equally spaced between the top
and bottom bars?? Any suggestions?

Here it is:


--- Code: ---; CAPBARS.LSP A PROGRAM TO DRAW A PIER CAP
; WITH REINF. BARS


  (DEFUN DTR (A) (* PI (/ A 180.0)))
  (DEFUN RTD (A) (/ (* A 180.0) PI))
(DEFUN C:CAPBARS ()   
 (SETVAR "CMDECHO" 0)
 (SETQ Z (GETVAR "CLAYER"))
 (GRAPHSCR)
 (command "osnap" "off" "")



(SETQ P1  (GETPOINT  "\nStart point for construction: "))

(setq w (getdist "\nPierCap width?:"))
(setq h (getdist "\nPierCap height?:"))
(setq ang 1.5708)

(setq p2 (polar p1 (-(dtr 90) ang) w)
      p3 (polar p2 (+(dtr 0) ang) h)
      p4 (polar p3 (+(dtr 90) ang) w)
)   
 
  (setvar "clayer" "3")
  (setvar "cecolor" "7")
  (command "line" p1 p2 p3 p4 "close" "")
  (redraw) ; end of drawing the outline

  (command "dimclrt" "1" "")
  (command "dimclre" "1" "")
  (command "dimscale" "12" "")
  (command "lunits" "4" "")
  (command "dimunit" "4" "")
  (command "dimtsz" "1/16" "")
  (command "dimtad" "1" "")
  (command "dimtih" "off" "")
  (command "dimjust" "0" "")
  (command "dimtad" "1" "")

  (setvar "cecolor" "1")
  (setvar "clayer" "defpoints")
  (setq p5 (polar p1 (+(DTR 90) ANG) 14))
  (command "dim" "ver"p1 p4 p5 "")
  (setq p6 (polar p1 (+(dtr 180) ang) 14))
  (command "dim" "hor" p1 p2 p6 "")
  (command "exit" "")
  (command "zoom" "e" "")
  (command "zoom" "0.9x" "")
  (redraw)


(setq bp1 (getpoint "\nStart point for reinf at lower left corner of piercap: "))


  (setq BW (getdist "\nPierCap width?:"))
  (setq BH (getdist "\nPierCap Height?:"))
  (setq ang 1.5708)
  (setq bp2 (polar bp1 (-(dtr 90) ang) bw)
      bp3 (polar bp2 (+(dtr 0) ang) bh)
      bp4 (polar bp3 (+(dtr 90) ang) bw)
  )   
 
  (setq bp5 (polar bp1 (-(dtr 90) ang) 3.5))
  (setq bp9 (polar bp5 (+(dtr 0) ang) 3))
  (setq bp10 (polar bp2 (+(dtr 90) ang) 15))
  (setq bp11 (polar bp10 (+(dtr 0) ang) 3))
  (setq bp7 (polar bp3 (+(dtr 90) ang) 15))
  (setq bp12 (polar bp7 (+(dtr 180) ang) 2))
  (setq bp8 (polar bp4 (+(dtr 180) ang) 3))
  (setq bp13 (polar bp8 (-(dtr 90) ang) 3.5))
  (setq bp6 (polar bp4 (-(dtr 90) ang) 3.5))
  (setq bp13 (polar bp6 (+(dtr 180) ang) 2))
 

 
  (setvar "cecolor" "8")
  (setvar "clayer" "reinf")
  (command "ortho" "on" )
  (command "pline" bp11 bp9 bp13 bp12 "")
  (command "fillet" "r" 1 "fillet" "polyline" "L")
  (setvar "cecolor" "7")
  (redraw)


  (setq bp14 (polar bp1 (-(dtr 90) ang) 15))
  (setq bp15 (polar bp14 (+(dtr 0) ang) 4))
  (setq bp16 (polar bp2 (+(dtr 90) ang) 3.5))
  (setq bp17 (polar bp16 (+(dtr 0) ang) 4))
  (setq bp18 (polar bp3 (+(dtr 90) ang) 3.5))
  (setq bp19 (polar bp18 (+(dtr 180) ang) 3))
  (setq bp20 (polar bp4 (-(dtr 90) ang) 15))
  (setq bp21 (polar bp20 (+(dtr 180) ang) 3))
 
 

 
  (setvar "cecolor" "8")
  (setvar "clayer" "reinf")
  (command "ortho" "on" )
  (command "pline" bp15 bp17 bp19 bp21 "")
  (command "fillet" "r" 1 "fillet" "polyline" "L")
  (setq bp22 (polar bp4 (+(dtr 180) ang) 4))
  (setq bp23 (polar bp3 (+(dtr 180) ang) 4))
  (setq bp24 (polar bp22 (-(dtr 90) ang) 3))
  (setq bp25 (polar bp23 (+(dtr 90) ang) 3))
  (command "pline" bp24 bp25 "")
  (setq bp26 (polar bp1 (+(dtr 0) ang) 5))
  (setq bp27 (polar bp2 (+(dtr 0) ang) 5))
  (setq bp28 (polar bp26 (-(dtr 90) ang) 3))
  (setq bp29 (polar bp27 (+(dtr 90) ang) 3))
  (command "pline" bp28 bp29 "")
  (setq bp30 (polar bp28 (+(dtr 90) ang) 0.25))
  (command "circle" bp30 "D" 0.50)
  (setq bp31 (polar bp29 (-(dtr 90) ang) 0.25))
  (command "circle" bp31 "D" 0.50)
  (setq bp32 (polar bp24 (+(dtr 90) ang) 0.25))
  (command "circle" bp32 "D" 0.50)
  (setq bp33 (polar bp25 (-(dtr 90) ang) 0.25))
  (command "circle" bp33 "D" 0.50)
  (setvar "cecolor" "7")
  (setvar "clayer" "text")
  (redraw)


  (redraw)
  (princ)
) ; end of defun
--- End code ---

Thanks,

vinnyg

<EDIT: ADDED CODE TAGS>

CAB:
"A picture is worth a thousands words." :-)   

Would you upload a drawing with the desired object?

Jeff_M:
After fixing a number of small errors and omissions (ended some commands with "" when not needed, added check for the layers used and added if not there.) these are the results I get....something doesn't look quite right......what should the final result look like?

vinnyg:

I will be happy to upload screen shot of the "Pier Cap" as soon as I discover how to
do it??

Somebody, please send instructions.....

I have it ready as a BMP file?

thanks.

vinnyg

Bob Wahr:
On the bar that has

--- Quote ---Pages: [1] | Go Up                         Reply | Notify of replies | Mark unread | Print 
--- End quote ---
below the last post, click reply.  On that page, click "Additional options"  You should see the attachment bit.

Navigation

[0] Message Index

[#] Next page

Go to full version