Author Topic: Get only numbers from string  (Read 1765 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2084
Get only numbers from string
« on: November 14, 2015, 05:37:41 PM »
(rtos ARCH#SIZE 2 0) = "2'-10\""

How do I strip this down to be: 210
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Get only numbers from string
« Reply #1 on: November 14, 2015, 05:54:36 PM »
(vl-list->string (vl-remove-if-not '(lambda (x)(< 47 x 58)) (vl-string->list (rtos ARCH#SIZE 3 0))))

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

GDF

  • Water Moccasin
  • Posts: 2084
Re: Get only numbers from string
« Reply #2 on: November 14, 2015, 06:27:48 PM »
Thank you Michael
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2084
Re: Get only numbers from string
« Reply #3 on: November 14, 2015, 06:35:13 PM »
This is how I'm using it, to tag old doors that have data attached. The new client calls out door sizes in a different format. Still working on cleaning up the code.



Code: [Select]
(defun c:DRTAG  () 
  ;;(rtos ARCH#SIZE 2 0) = "2'-10\""
  ;;(vl-list->string (vl-remove-if-not '(lambda (x)(< 47 x 58)) (vl-string->list (rtos ARCH#SIZE 3 0))))

  (if (= ARCH#BLKX nil)(ARCH:BLKNAM "SYMDR" (strcat ARCH#CUSF "SYMS/")))
  (setq scf (getvar "dimscale"))
  (ARCH:CUSTOM_LAYERS-SYMB-DOOR)   
  (setvar "cmdecho" 0)

  (setq objx (entget (car (entsel "\n* Select Door to Tag *"))))
  (setq xdli (cdr (assoc 2 (entget (cdar objx) '("DRWDWLVR")))))
  (setq xszx (substr xdli 5 (- (strlen xdli) 8)))
  ;;(setq size (strcat (rtos ARCH#SIZE 2 0) "x80"))
  (setq insx (cdr (assoc 10 objx)))

  (setq name (vl-list->string (vl-remove-if-not '(lambda (x)(< 47 x 58)) (vl-string->list (rtos ARCH#SIZE 3 0)))))
  (setq size (strcat name "x80"))

  (command
    "insert"
    (strcat ARCH#CUSF "SYMS/" "SYMDR")
    "ps"
    SCF
    insx
    SCF
    ""
    ""
    size
    "")
(princ))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Get only numbers from string
« Reply #4 on: November 14, 2015, 07:11:30 PM »