Results 1 to 4 of 4

Thread: Need help de-bugging a routine

  1. #1
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Unhappy Need help de-bugging a routine

    I wrote this routine that creates a basic rectangular foundation plan (walls with footings centered under it).
    It asks for start point and user input for outside foundation dimensions, wall thickness and footing width, works pretty sweet too.

    I am sure there's a better way to do this, but this is the depth of my knowledge and I'm pretty proud of it.
    Code:
    ;;;;Draws a FOUNDATION plan ; rectangular foundation wall with footing centered below
    ;;;;**********************************************************************************
    (defun C:fndn (/ p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 LR1 LR2 LR3 osm la)
    (setq cmde (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (command "_units" "4" "16" "1" "2" "" "n")
    (setq strt_point (getpoint "Select start Point (lower left corner of fndn) Type a Coordinate or Pick the Point "))(terpri)
    (setq len (getdist "How wide is your FNDN? (horizontally) "))(terpri)
    (setq wid (getdist "How high is your FNDN? (vertically) "))(terpri)
    (setq thk (getdist "How thick is your FNDN? (wall thickness) "))(terpri)
    (setq ftg (getdist "How wide is your FOOTING? (centered below wall) "))(terpri)
    (setq thkhalf (/ thk 2))
    (setq ftghalf (/ ftg 2))
    ;;creates points for outside wall perimeter (footprint)
    (setq Xp1 (car strt_point))
    (setq yp1 (cadr strt_point))
    (setq p1 (list xp1 yp1 0))
    (setq xp2 (+ xp1 len))
    (setq yp2 yp1)
    (setq p2 (list xp2 yp2 0))
    (setq xp3 xp2)
    (setq yp3 (+ yp2 wid))
    (setq p3 (list xp3 yp3 0))
    (setq p4 (list xp1 yp3 0))
    ;;Creates points for inside wall perimeter (outside wall + thickness inward) 
    (setq xp4 (+ xp1 thk))
    (setq yp4 (+ yp1 thk))
    (setq p5 (list xp4 yp4 0))
    (setq xp5 (- xp2 thk))
    (setq yp5 (+ yp2 thk))
    (setq p6 (list xp5 yp5 0))
    (setq xp6 xp5)
    (setq yp6 (- yp3 thk))
    (setq p7 (list xp6 yp6 0))
    (setq xp7 xp4)
    (setq yp7 yp6)
    (setq p8 (list xp7 yp7 0))
    ;;Creates points for wall centerline for reference
    (setq xp8 (+ xp1 thkhalf))
    (setq yp8 (+ yp1 thkhalf))
    (setq p9 (list xp8 yp8 0))
    (setq xp9 (- xp2 thkhalf))
    (setq yp9 (+ yp2 thkhalf))
    (setq p10 (list xp9 yp9 0))
    (setq xp10 xp9)
    (setq yp10 (- yp3 thkhalf))
    (setq p11 (list xp10 yp10 0))
    (setq xp11 xp8)
    (setq yp11 yp10)
    (setq p12 (list xp11 yp11 0))
    ;;Creates points for outside footing perimeter
    (setq xp12 (- xp8 ftghalf))
    (setq yp12 (- yp8 ftghalf))
    (setq p13 (list xp12 yp12 0))
    (setq xp13 (+ xp9 ftghalf))
    (setq yp13 (- yp9 ftghalf))
    (setq p14 (list xp13 yp13 0))
    (setq xp14 xp13)
    (setq yp14 (+ yp10 ftghalf))
    (setq p15 (list xp14 yp14 0))
    (setq xp15 xp12)
    (setq yp15 yp14)
    (setq p16 (list xp15 yp15 0))
    ;;Creates points for inside footing perimeter (outside footing + thickness inward)
    (setq xp16 (+ xp8 ftghalf))
    (setq yp16 (+ yp8 ftghalf))
    (setq p17 (list xp16 yp16 0))
    (setq xp17 (- xp9 ftghalf))
    (setq yp17 (+ yp9 ftghalf))
    (setq p18 (list xp17 yp17 0))
    (setq xp18 xp17)
    (setq yp18 (- yp10 ftghalf))
    (setq p19 (list xp18 yp18 0))
    (setq xp19 xp16)
    (setq yp19 yp18)
    (setq p20 (list xp19 yp19 0))
    (setq osm (getvar "osmode"))
    (setq la (getvar "clayer"))
     (SETQ LR1 (TBLSEARCH "LAYER" "S-FNDN-N"))   
     (SETQ LR2 (TBLSEARCH "LAYER" "S-FNDN-FTNG-N"))
     (SETQ LR3 (TBLSEARCH "LAYER" "S-FNDN-NPLT"))
      (IF (= LR1 NIL)
      (command "layer" "make" "S-FNDN-N" "color" "3" "" "lw" "0.35" "" ""))
      (IF (= LR2 NIL)
      (command "layer" "make" "S-FNDN-FTNG-N" "COLOR" "3" "" "lw" "0.35" "" "LT" "HIDDEN2" "" ""))
      (IF (= LR3 NIL)
      (command "layer" "make" "S-FNDN-NPLT" "COLOR" "140" "" "PLOT" "N" "" "lw" "0.18" "" "LT" "CENTER2" "" ""))
    (setvar "osmode" 16384)
    (command "layer" "t" "S-FNDN-N" "S" "S-FNDN-N" "")
    (command "pline" p1 p2 p3 p4 "c")
    (command "pline" p5 p6 p7 p8 "c")
    (command "layer" "t" "S-FNDN-NPLT" "S" "S-FNDN-NPLT" "")
    (command "pline" p9 p10 p11 p12 "c")
    (command "layer" "t" "S-FNDN-FTNG-N" "S" "S-FNDN-FTNG-N" "")
    (command "pline" p13 p14 p15 p16 "c")
    (command "pline" p17 p18 p19 p20 "c")
    (command "zoom"  "e"  "zoom"  ".9x" )
    (setvar "osmode" osm)
    (setvar "clayer" la)
    (setvar "cmdecho" cmde)
    (princ)
    )
    Anywho... My problem is: I wrote another simple routine for drawing piers (see below), and it works ok, but with issues.
    If I run the FNDN routine above and then this routine it works great.
    If I just run this PIER routine all by itself, it trips up, it places the node (point) and line (with zero length) at the same point and that's it.
    Code:
     
    ;;;;Draws a PIER (in plan view) centered on picked point ; 
    ;;;;**********************************************************************************
    (defun C:pier (/ p1 p2 p3 p4 p5 LR1 LR2 LR3 osm la)
    (setq cmde (getvar "cmdecho"))
    (setvar "cmdecho" 1)
    (setvar "pdmode" 0)
    (command "_units" "4" "16" "1" "2" "" "n")
    (setq strt_point (getpoint "Select start Point (center of PIER) Type a Coordinate or Pick the Point "))(terpri)
    (setq len (getdist "How wide is your PIER? (horizontally) "))(terpri)
    (setq wid (getdist "How high is your PIER? (vertically) "))(terpri)
    (setq lenhalf (/ len 2))
    (setq widhalf (/ wid 2))
    (setq Xp1 (car strt_point))
    (setq yp1 (cadr strt_point))
    (setq p1 (list xp1 yp1 0))
    (setq xp2 (- xp1 lenhalf))
    (setq yp2 (- yp1 widhalf))
    (setq p2 (list xp2 yp2 0))
    (setq xp3 (+ xp2 len))
    (setq yp3 yp2)
    (setq p3 (list xp3 yp3 0))
    (setq xp4 xp3)
    (setq yp4 (+ yp3 wid))
    (setq p4 (list xp4 yp4 0))
    (setq p5 (list xp2 yp4 0))
    (setq osm (getvar "osmode"))
    (setq la (getvar "clayer"))
     (SETQ LR1 (TBLSEARCH "LAYER" "S-FNDN-N"))
     (SETQ LR2 (TBLSEARCH "LAYER" "G-ANNO-NPLT")) 
      (IF (= LR1 NIL)  
      (command "layer" "make" "S-FNDN-N" "color" "3" "" "lw" "0.35" "" ""))
      (IF (= LR2 NIL)
      (command "layer" "make" "G-ANNO-NPLT" "COLOR" "140" "" "PLOT" "N" "" "lw" "0.18" "" ""))
    (setvar "cmdecho" cmde)
    (command "layer" "t" "G-ANNO-NPLT" "S" "G-ANNO-NPLT" "")
    (command "point" p1)
    (command "layer" "t" "S-FNDN-N" "S" "S-FNDN-N" "")
    (command "pline" p2 p3 p4 p5 "c")
    (setvar "osmode" osm)
    (setvar "clayer" la)
    (princ)
    )
    Any ideas?
    Probably something stupid..

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Need help de-bugging a routine

    Localize all your variables and the following variables are still global .

    Code:
    cmde len lenhalf strt_point wid widhalf xp1 xp2 xp3 xp4 yp1 yp2 yp3 yp4
    and setvar the osmode to zero after getting the value of it without setting them .

    Like this ..

    Code:
    (setq osm (getvar "osmode"))
    (setvar 'osmode 0)
    And try again .

  3. #3
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: Need help de-bugging a routine

    Quote Originally Posted by Tharwat View Post
    Localize all your variables and the following variables are still global .

    Code:
    cmde len lenhalf strt_point wid widhalf xp1 xp2 xp3 xp4 yp1 yp2 yp3 yp4
    and setvar the osmode to zero after getting the value of it without setting them .

    Like this ..

    Code:
    (setq osm (getvar "osmode"))
    (setvar 'osmode 0)
    And try again .
    Thanks! That did it.
    So it was because I didn't have all my variables localized?

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Need help de-bugging a routine

    Quote Originally Posted by tedg View Post
    Thanks! That did it.
    You're welcome anytime

    Quote Originally Posted by tedg View Post
    So it was because I didn't have all my variables localized?
    Correct , plus setting the osmode variable to zero to avoid the intersections of osnap nods .

Similar Threads

  1. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 10:33 PM
  2. Bugging Door Details
    By TerribleTim in forum Revit Architecture - General
    Replies: 11
    Last Post: 2012-05-03, 08:24 PM
  3. Replies: 2
    Last Post: 2007-04-20, 09:51 AM
  4. Roofs, Windows and the Cut Plane (was 2 things bugging me...)
    By Vaioarch in forum Revit Architecture - General
    Replies: 6
    Last Post: 2006-02-17, 04:37 PM
  5. I have two things bugging me right now in Revit.
    By Vaioarch in forum Revit Architecture - Tips & Tricks
    Replies: 2
    Last Post: 2006-01-19, 09:59 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •