Author Topic: ft or inches  (Read 4319 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
ft or inches
« on: March 14, 2005, 12:58:04 PM »
I just can't think of how to do this:
I want to ask a user for an input of a number and allow them to supply inches or feet and have lisp know the difference. I just can't think of how to do it. Anybody got any ideas. Seems like it shouldn't be too hard.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ft or inches
« Reply #1 on: March 14, 2005, 01:03:17 PM »
Use getstring and then distof.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
ft or inches
« Reply #2 on: March 14, 2005, 01:09:11 PM »
Use the getdist function.
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.

daron

  • Guest
ft or inches
« Reply #3 on: March 14, 2005, 01:19:02 PM »
Thank you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ft or inches
« Reply #4 on: March 14, 2005, 01:19:46 PM »
Hey Charles, try this --

(setvar "lunits" 2)
(getdist) [enter] 12' [enter]

*shladdap*, rake in the face. :(

Subtitle: Getdist's ability to accept keyed input is a function of the lunits sys var setting.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
ft or inches
« Reply #5 on: March 14, 2005, 01:23:52 PM »
CAB, that is what I was looking for. I knew it was there, I just needed to try it. Of course, I'll have to take MP's above thought to test.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
ft or inches
« Reply #6 on: March 14, 2005, 02:04:39 PM »
Quote from: MP
Hey Charles, try this --

(setvar "lunits" 2)
(getdist) [enter] 12' [enter]

*shladdap*, rake in the face. :(

Subtitle: Getdist's ability to accept keyed input is a function of the lunits sys var setting.
:?:
Why would you press [enter] before your 12'?

What happens with
(getstring) [enter] 12' [enter] :)

I was thinking getdist because it will allow many format options for user input.
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.

daron

  • Guest
ft or inches
« Reply #7 on: March 14, 2005, 02:48:34 PM »
Here's the solution to MP's problem:
Code: [Select]
(if (or (< (getvar 'lunits) 3) (> (getvar 'lunits) 4))
    (setq lunitnum (getvar 'lunits))
    (setvar 'lunits 4)
   )
(setq height (getdist "\nHeight of Wall: "))
(setvar 'lunits lunitnum)


Note: Any value other than 3 or 4 will result in the inability to use the ft (') mark.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
ft or inches
« Reply #8 on: March 14, 2005, 02:59:11 PM »
Oh, I see now. The fog is starting to lift.
Sorry Michael, as usual your reply went right over my pointy little head. :oops:
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ft or inches
« Reply #9 on: March 14, 2005, 03:17:27 PM »
No worries Charles. You correctly pointed out the use of getdist; I just pointed out one mustn't make assumptions about its behavior. :)

And now for something completely different:

Code: [Select]
(defun distanceof ( x  / result )
    (vl-catch-all-apply
       '(lambda ()
            (vl-some
               '(lambda (units) (setq result (distof x units)))
                (list (getvar "lunits") 4 5 2 1)
            )
        )
    )    
    result
)


:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
ft or inches
« Reply #10 on: March 14, 2005, 03:43:03 PM »
That's is a thing of beauty Michael.
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
ft or inches
« Reply #11 on: March 14, 2005, 04:17:39 PM »
Thank you Mark, meant to be (primarilly) demonstrative. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst