Author Topic: Imperial String to Imperial distance  (Read 2420 times)

0 Members and 1 Guest are viewing this topic.

SPDCad

  • Bull Frog
  • Posts: 453
Imperial String to Imperial distance
« on: May 16, 2005, 02:25:59 PM »
Does anyone have a lisp that will convert an imperial distance in the form of a string to the actual imperial distance.

example

input:  "18'2\" "
output:  18'-2"

I am requesting user input in a dialog box and the value is returned as a string not a number.

Any help would be greatly appreciated.
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

whdjr

  • Guest
Imperial String to Imperial distance
« Reply #1 on: May 16, 2005, 02:57:54 PM »
This is probably your best bet:
Quote
Converts a string into a real number
(atof string)

Arguments

string

A string to be converted into a real number.

Return Values

A real number.

Examples

Command: (atof "97.1")
97.1
Command: (atof "3")
3.0
Command: (atof "3.9")

3.9

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Imperial String to Imperial distance
« Reply #2 on: May 16, 2005, 03:04:13 PM »
I'm not sure I understand, but given --

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
)

Perhaps --

Code: [Select]
(rtos (distanceof "18'2\"") 4 2)

=> "18'-2\""
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

SPDCad

  • Bull Frog
  • Posts: 453
Imperial String to Imperial distance
« Reply #3 on: May 16, 2005, 03:15:15 PM »
Quote from: MP
(rtos (distanceof "18'2\"") 4 2)=> "18'-2\""


Thats its, I forgot about the DISTOF command!
Thanks MP.

:O)
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs