Author Topic: Slope to Snapang  (Read 3120 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Slope to Snapang
« on: April 03, 2007, 12:43:31 PM »
I am looking for a function to set the snapang based upon the slope of a line to be drawn at.
For example I want to draw a line at the slope of 5:12

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Slope to Snapang
« Reply #1 on: April 03, 2007, 12:49:53 PM »
Something like??
Code: [Select]
(setvar "snapang" (angle '(0.0 0.0) (list (getreal "\n X value: ") (getreal "\n Y value: "))))
Tim

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

Please think about donating if this post helped you.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Slope to Snapang
« Reply #2 on: April 03, 2007, 01:31:27 PM »
Hi,

Another way, 5:12, 5/12 or 0.416666667 forms are accepted.

Code: [Select]
(defun c:slope (/ sl)
  (or (member "geomcal.arx" (arx))
      (arxload "geomcal")
  )
  (and
    (setq sl (getstring "\nSlope: "))
    (setq sl (cal (vl-string-subst "/" ":" sl)))
    (setvar "SNAPANG" (atan sl))
  )
  (princ)
)
« Last Edit: April 03, 2007, 02:14:37 PM by gile »
Speaking English as a French Frog

GDF

  • Water Moccasin
  • Posts: 2081
Re: Slope to Snapang
« Reply #3 on: April 03, 2007, 02:30:32 PM »
Gile

Thanks. That is what I needed.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Slope to Snapang
« Reply #4 on: April 03, 2007, 02:39:01 PM »
Here is another version of Tim's.The 12 is a given for me.
Code: [Select]
(defun c:slope (/ rise)
  (and
    (setq rise (getreal "\nSlope: ?/12  "))
    (or (> 12.001 rise 0) (prompt "\nOut of range!"))
    (setvar "snapang" (angle '(0.0 0.0) (list 12. rise)))
  )
  (print)
)
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.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Slope to Snapang
« Reply #5 on: April 03, 2007, 03:42:05 PM »
Thanks everyone. I modified my old code with the new. I'm alearn'n.

Code: [Select]
(defun SHOW_LWID ()
    (cond
      ((= LWID "Select")(mode_tile "accept" 0)(set_tile "msg" (strcat "New Snapang = 0/12"))(setvar "snapang" 0))     
    )
  )
  (setq SET_WIDTH '("Select"  " 0.125"  " 0.25"   " 0.375"
    " 0.5"    " 0.625"  " 0.75"   " 0.875" " 1" " 1.5"
    " 2"      " 3"      " 3.25"   " 3.5" " 3.75"
    " 4"      " 4.25"   " 4.5"    " 4.75" " 5"
    " 5.25"   " 5.5"    " 5.75"   " 6" " 6.25"
    " 6.5"    " 6.75"   " 7"      " 7.25" " 7.5"
    " 7.75"   " 8"      " 8.25"   " 8.5" " 8.75"
    " 9"      "10"      "11"      "12"
   )
  ) 

  (defun SnapAngleFunction ()
    (or (member "geomcal.arx" (arx))
      (arxload "geomcal")
    )
    (and           
      (setvar "SNAPANG" (atan (/ 12 (distof LWID))))
    ) 
  )

  (defun RESET-SAU ()     
    (set_tile "msg" (strcat "New Snapang = 0/12"))   
    (mode_tile "15" 0)
    (mode_tile "30" 0)
    (mode_tile "45" 0)
    (mode_tile "60" 0)
    (mode_tile "75" 0)
    (mode_tile "90" 0)
    (mode_tile "PA1" 0)
    (mode_tile "PA2" 0)
    (mode_tile "DEGREES_SLOPE" 0)
    (mode_tile "SLOPE_IN_12" 0)   
    (mode_tile "accept" 1)
    (mode_tile "snapang" 0)
    (mode_tile "image_rotation" 0)
    (mode_tile "new_value" 0)
  )
  (defun GET_WIDTH ()   
    (mode_tile "15" 1)
    (mode_tile "30" 1)
    (mode_tile "45" 1)
    (mode_tile "60" 1)
    (mode_tile "75" 1)
    (mode_tile "90" 1)
    (mode_tile "PA1" 1)
    (mode_tile "PA2" 1)
    (mode_tile "DEGREES_SLOPE" 1)
    (mode_tile "SLOPE_IN_12" 1)   
    (mode_tile "accept" 0)
    (mode_tile "snapang" 1)
    (mode_tile "image_rotation" 1)
    (mode_tile "new_value" 1)   
   
    (setq SLOP2 (/ (distof LWID) 12))   
    (cond
      ((/= SLOP2 nil)(set_tile "msg" (strcat "New Snapang = " LWID "/12  [" (rtos SLOP2 2 3) "]")))
      ((= SLOP2 nil)(set_tile "msg" (strcat "New Snapang = " LWID "/12")))
    )
    (mode_tile "calc-len" 1)
    (mode_tile "calc-hgt" 1)
    (mode_tile "pick-dist" 0)
  ) 

  (start_list "widthlist")
  (mapcar 'add_list SET_WIDTH)
  (end_list)   

(start_dialog)
  (cond
    ((= op "snapang")
      (progn             
(command "snapang" st%new_value)
(prompt "\n* Done Setting new Snap Angle *")       
      )
    )   
    ((= op "snapang2")
      (progn             
;;(princ "\n* Snap Angle has been successfully reset *")
        (SnapAngleFunction)
(prompt "\n* Done Setting new Snap Angle *")       
      )
    )
    ((= op "draw@ang")
      (progn             
        (setvar "cmdecho" 0)
        (SnapAngleFunction)
        (setq pnt1 (getpoint "\n* Pick beginning point of Line *"))
        (setq pnt2 (getpoint pnt1 "\n* Pick beginning point of Line *"))
        (command "line" pnt1 pnt2 "")                 
        (drawmirror)
      )
    )

[code/]

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Slope to Snapang
« Reply #6 on: April 03, 2007, 03:43:56 PM »
OK, two more variations.

Code: [Select]
;;  CAB  04.03.07
;;  Enter rise and Left Or Right Slope
(defun c:slope (/ tmp run)
  (or *rise (setq *rise 6.))
  (and (setq tmp (getreal (strcat "\nSlope: ?/12 <" (rtos *rise 2 2) "> ")))(setq *rise tmp))
  (and
    (or (> 12.001 *rise 0) (prompt "\nOut of range!"))
    (not (initget 0 "Right Left"))
    (if (= "Right" (getkword "\nWhich slope? [Right/Left] < Left >: "))
      (setq run -12.)
      (setq run 12.)
    )
    (setvar "snapang" (angle '(0.0 0.0) (list run *rise)))
  )
  (print)
)

(defun c:sl0()  ;  reset to zero
  (setvar "snapang" 0.0)
  (princ)
)



This one enter "SLO 0" to reset the snap angle, use "SLO 4" for 4/12
Code: [Select]
;;  CAB 04.03.07
;;  Enter SLO then space then the Rise, use negative number for Right Slope
(defun c:slo (/ rise)
  (and
    (setq rise (getreal "\nEnter Slope Rise: ?/12  "))
    (or (>= 12.00 rise -12) (prompt "\nOut of range! 0-12"))
    (setvar "snapang" (angle '(0.0 0.0) (list 12. rise)))
  )
  (princ)
)
« Last Edit: April 26, 2007, 01:05:07 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
Re: Slope to Snapang
« Reply #7 on: April 03, 2007, 03:45:31 PM »
Wow Gary you go all out. :-)
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.

Tom

  • Guest
Re: Slope to Snapang
« Reply #8 on: April 03, 2007, 06:09:23 PM »
Quote
       (setq pnt1 (getpoint "\n* Pick beginning point of Line *"))
        (setq pnt2 (getpoint pnt1 "\n* Pick beginning point of Line *"))

No end to your line Gary?

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Slope to Snapang
« Reply #9 on: April 26, 2007, 12:45:29 PM »
Hey guys am I too late?  :-P

anyway I've been working on some quadrant stuff lately and I penned this little guy yesterday.  It asked for the slope (in inches) then asked for a start point.  It then set up quadrants and depending on were you move the cursor the angle sets itself to that quadrant.  Select the correct quadrant then select your endpoint.  I've been meaning to write one of these for a while now, I do the ole' line 12 over, line up 6 then connect the 2 move the slope to were it is needed. :realmad:  This is much better.

Thanks for the inspiration.
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
Re: Slope to Snapang
« Reply #10 on: April 26, 2007, 12:48:54 PM »
Or you can modify my example in my article: http://www.theswamp.org/index.php?topic=5203.0
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

GDF

  • Water Moccasin
  • Posts: 2081
Re: Slope to Snapang
« Reply #11 on: April 26, 2007, 03:12:02 PM »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64