Author Topic: screwy dimension question  (Read 3034 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
screwy dimension question
« on: August 23, 2004, 04:51:22 PM »
hey guys i experience a problem every once in awhile with my dimensions which i'm trying to solve. from time to time when i dimension i will pick the first point then drag my mouse in the direction i want the dimesion and type "4". the dimension will read as 4 1/32" or some weird dimension. another problem is sometimes when i'm drawing i will have ortho on and drag and put in a number and it will draw it at some crazy angle. anyway i think i may have isolated the problem to this lisp i'll include but not sure. the problem i think is some routine i have is changing my ucs from world to 2kucs or something like that. if this isn't the lisp could someone tell me how i might find out where this ucs is coming from and nuke it.

Code: [Select]
;;CADALYST 04/04 Tip1944:  LSB.LSP  Draw a Breakline       (c) 2004 Theodorus Winata

;;;  DESCRIPTION
;;;  Break Marks with variable vertex height. It will place
;;;  the breaks between start point and end point. S-Breaks will
;;;  be drawn at user specified end points. The dialogue contains
;;;  a list of layer selections and edit boxes to control the size
;;;  of the breaks. The dialogue is defined in the LSB.DCL file.
;;;
;;;  By Theodorus Winata
;;;  1024 - 89 Avenue S.W.
;;;  Calgary, Alberta
;;;  Canada T2V OW4
;;;
;;;********** Set Layer **********
(defun set-layer ()
   (command "_.layer" "set" NLA "")
   (princ)
);;set-layer

;;;********** Set Up The Defaults function **********
(defun round ()
   (setvar "OSMODE" 1)
   (setq PT1 (getpoint "\nPick Starting Point: ")
         PT2 (getpoint PT1 "\nPick Ending Point: ")
         AN  (angle PT1 PT2)
         AN1 (angle PT2 PT1)
         AN2 (- AN1 0.380506377)
         AN3 (- AN  0.380506377)
         AN4 (+ AN  0.380506377)
         DIA (distance PT1 PT2)
         RAD (/ DIA 2.0)
         XOF (/ DIA 10.0)
         YOF (/ DIA 4.0)
         PT3 (polar PT2 AN2 (sqrt (+ (expt XOF 2)
             (expt YOF 2))))
         PT4 (polar PT2 AN1 RAD)
         PT5 (polar PT1 AN3 (sqrt (+ (expt XOF 2)
             (expt YOF 2))))    
         PT6 (polar PT1 AN4 (sqrt (+ (expt XOF 2)
             (expt YOF 2))))
   );;setq
   (setvar "OSMODE" 0)
   (command "_.spline" PT2 PT3 PT4 PT5 PT1 PT6 PT4 "" "" "")
);;round

;;;********** Mode Tile Section **********
(defun break-l (VAL)
   (if (= VAL "1")
      (progn
(mode_tile "nbreaks" 0)
(mode_tile "vheight" 0)
(mode_tile "nbks" 1)
         (mode_tile "twall" 1)
         (mode_tile "vhgt" 1)
      );;progn
   );;if
);;break-l

(defun tube (VAL)
   (if (= VAL "1")
     (progn
      (mode_tile "twall" 0)
      (mode_tile "nbreaks" 1)
      (mode_tile "vheight" 1)
      (mode_tile "nbks" 1)
      (mode_tile "vhgt" 1)
     )
   );;if
);;tube

(defun break-s (VAL)
   (if (= VAL "1")
      (progn
(mode_tile "nbks" 0)
(mode_tile "vhgt" 0)
(mode_tile "nbreaks" 1)
         (mode_tile "twall" 1)
         (mode_tile "vheight" 1)
      );;progn
   );;if
);;break-s

(defun solrod ()
   (mode_tile "nbks" 1)
   (mode_tile "vhgt" 1)
   (mode_tile "nbreaks" 1)
   (mode_tile "twall" 1)
   (mode_tile "vheight" 1)
);;solrod

;;;********** Function to Change Slide Image **********
(defun lsbreak (sld /)
   (start_image "image")
   (fill_image 0 0 width height 0)
   (slide_image 0 0 width height (strcat "lsb.slb (" sld ")"))
   (end_image)
);;lsbreak

;;;********** Main Function **********
(defun C:LSB (/ APP C1 C2 CME DCL_ID DS DX E1 E2 E3 E4 E5 EP
                HEIGHT IRA LALIST LNAME M:ERR NEXT NLA OSM P1 P2  
                P3 P4 P5 P6 PT1 PT2 PT7 PT8 PT9 SP SS ST WIDTH YN)
   (setq M:ERR *ERROR* *ERROR* *MERR*
         CME (getvar "CMDECHO")
         OSM (getvar "OSMODE")
         NLA (getvar "CLAYER")
YN ""
   );;setq
   (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (setvar "PLINEWID" 0)

;;;********** Make a List of Defined Layers **********
   (setq LNAME (cdr (assoc 2 (tblnext "layer" T)))
         LALIST (list LNAME)
   );;setq
   (while (/= LNAME nil)
      (setq LNAME (cdr (assoc 2 (tblnext "layer"))))
         (if (/= LNAME nil)
            (progn
               (setq APP (list LNAME)
                     LALIST (append LALIST APP)
               );;setq
            );;progn
         );;if
   );;while
   (tblnext "layer" "rewind")
   (setq LALIST (acad_strlsort LALIST))

;;;********** Set Up Values **********  
   (if (not NB)    (setq NB 1))
   (if (not NBS)   (setq NBS 1))
   (if (not VH)    (setq VH 0.625))
   (if (not VHS)   (setq VHS 0.750))
   (if (not WAT)   (setq WAT 0.375))
   (if (not BREAK) (setq BREAK "line"))
   (setq DCL_ID (load_dialog "LSB.DCL"))
   (if (not (new_dialog "LSB" DCL_ID)) (exit))
   (start_list "llist")
   (mapcar 'add_list LALIST)
   (end_list)
   (setq WIDTH  (dimx_tile "image")
         HEIGHT (dimy_tile "image")
   );;setq

;;;********** Set Tile Section **********
   (set_tile "layer" NLA)
   (set_tile "nbreaks" (itoa NB))
   (set_tile "vheight" (rtos VH))
   (set_tile "nbks"    (itoa NBS))
   (set_tile "vhgt"    (rtos VHS))
   (set_tile "twall"   (rtos WAT))  
   (set_tile "error" "Copyright (C) \"Theo Winata & You 2003\"")
   (cond
      ((= BREAK "line")
       (set_tile "line" "1") (break-l "1")
       (lsbreak "LINE")
      )
      ((= BREAK "line_s")
       (set_tile "line_s" "1") (break-s "1")
       (lsbreak "LINE-S")
      )
      ((= BREAK "rod")
       (set_tile "rod" "1") (solrod)
       (lsbreak "ROD")
      )
      ((= BREAK "tube")
       (set_tile "tube" "1") (tube "1")
       (lsbreak "Tube")
      )
   );;cond

;;;********** Action Tile Section **********
   (action_tile "llist" "(setq NLA (nth (atoi $value) LALIST))
   (set_tile \"layer\" NLA)")
   (action_tile "layer"   "(setq NLA $value)")
   (action_tile "nbreaks" "(setq NB (atoi $value))")
   (action_tile "vheight" "(setq VH (distof $value))")
   (action_tile "nbks"    "(setq NBS (atoi $value))")
   (action_tile "vhgt"    "(setq VHS (distof $value))")  
   (action_tile "twall"   "(setq WAT (distof $value))")
   (action_tile "line"    "(setq BREAK \"line\") (break-l $value) (lsbreak \"LINE\")")
   (action_tile "line_s"  "(setq BREAK \"line_s\") (break-s $value) (lsbreak \"LINE-S\")")  
   (action_tile "rod"     "(setq BREAK \"rod\") (solrod) (lsbreak \"ROD\")")
   (action_tile "tube"    "(setq BREAK \"tube\") (tube $value) (lsbreak \"Tube\")")
   (action_tile "accept"  "(done_dialog 1)")
   (action_tile "cancel"  "(done_dialog 0)")

;;;********** Start Dialog and Execute Selection **********
   (setq NEXT (start_dialog))

   (if (= NEXT 1)
      (while (= YN "")
         (progn
            (set-layer)
            (cond
               ((= BREAK "line")
                (setq SP (getpoint "\nStart of Break Line: ")
                      EP (getpoint SP "\nEnd of Break Line: ")
                      DS (distance SP EP)
                      AN (angle SP EP)
                      ST (/ (- DS (* VH NB)) (+ NB 1))
                      DX (+ VH ST)
                      P1 (polar SP AN ST)
                      P2 (polar P1 (+ AN (* PI 1.58)) VH)
                      P3 (polar P2 (+ AN (* PI 0.42)) (* VH 2))
                      P4 (polar P1 AN VH)
                      SS (ssadd)
                );;setq
                (repeat NB
                   (command "_.pline" SP P1 P2 P3 P4 "")
                   (ssadd (entlast) SS)
                   (setq SP (polar SP AN DX)
                         P1 (polar P1 AN DX)
                         P2 (polar P2 AN DX)
                         P3 (polar P3 AN DX)
                         P4 (polar P4 AN DX)
                   );;setq
                );;repeat
                (command "_.pedit" SS "J" SS "" "")
                (setq P4 (getvar "lastpoint"))
                (command "_.pline" P4 EP "" "_.pedit" "L" "J" SS "" "")
               );;if
      ((= BREAK "line_s")
                (setq SP (getpoint "\nStart of Break Line: ")
                      EP (getpoint SP "\nEnd of Break Line: ")
                      DS (distance SP EP)
                      AN (angle SP EP)
                      ST (/ (- DS (* VHS NBS)) (+ NBS 1))
                      DX (+ VHS ST)
                      P1 (polar SP AN ST)
     P2 (polar P1 (+ AN (* pi 1.4220211)) (/ VHS 1.6169194))
     P3 (polar P2 AN (/ VHS 1.25))
     P6 (polar SP AN DX)
     P5 (polar P6 (+ AN (/ pi 2.3695497)) (/ VHS 1.6169194))
     P4 (polar P5 (+ AN pi) (/ VHS 1.25))
     C1 (polar P2 AN (/ VHS 2.5))
     C2 (polar P4 AN (/ VHS 2.5))
     SS (ssadd)
       );;setq
       (repeat NBS
          (command "_.pline" SP P1 P2 "")
          (setq E1 (entlast))
          (command "_.Arc" "C" C1 P2 P3)
          (setq E2 (entlast))
          (command "_.pline" P3 P4 "")
          (setq E3 (entlast))
          (command "_.Arc" P4 "C" C2 "A" "-180")
          (setq E4 (entlast))
          (command "_.pline" P5 P6 "")
          (setq E5 (entlast))
          (command "_.pedit" E1 "J" E2 E3 E4 E5 "" "")
          (ssadd (entlast) SS)
          (setq SP (polar SP AN DX)
        P1 (polar P1 AN DX)
        P2 (polar P2 AN DX)
        C1 (polar C1 AN DX)
        P3 (polar P3 AN DX)
        P4 (polar P4 AN DX)
        C2 (polar C2 AN DX)
        P5 (polar P5 AN DX)
        P6 (polar P6 AN DX)
          );;setq
       );;repeat
       (command "_.pedit" SS "J" SS "" "")
       (setq P6 (getvar "lastpoint"))
       (command "_.Pline" P6 EP "" "_.Pedit" "L" "J" SS "" "")
      );;if
               ((= BREAK "rod")
                (round)
               );;if
               ((= BREAK "tube")
                (round)
                (setq IRA (- (/ DIA 2) WAT)
                      PT8 (polar PT4 AN1 (- RAD WAT))
                      PT7 (polar PT4 (+ AN1 0.244978663) (sqrt (+
                          (expt (/ IRA 2) 2) (expt (/ IRA 2) 2))))
                      PT9 (polar PT4 (- AN1 0.244978663) (sqrt (+
                          (expt (/ IRA 2) 2) (expt (/ IRA 2) 2))))
                );;setq
                (setvar "OSMODE" 0)
       (command "_.spline" PT4 PT7 PT8 PT9 PT4 "" "" "")
               );;if
            );;cond
   (setq YN (strcase (getstring "\nMore Breaks? [Yes/No] <Y>: ")))
            (if (= YN "Y") (setq YN ""))
         );;progn
      );;while
   );;if
   (unload_dialog DCL_ID)
   (command "_.layer" "set" "0" "")
   (setvar "CMDECHO" CME)
   (setvar "OSMODE" OSM)
   (setq *ERROR* M:ERR M:ERR nil)
   (princ)
);;C:LSB