LASSAADTH Posted June 2, 2015 Share Posted June 2, 2015 I programmme a lisp in autocad, I want to insert a point with coordinates {(X + 10), (X + 100)} in my drawing I have a text in the form: X: 50.00m what is the function that allows me to just get (extract) the value 50.00 by selecting text in AutoCAD. I want to use this value in certain functions. Thank you for your aid. Quote Link to comment Share on other sites More sharing options...
GP_ Posted June 2, 2015 Share Posted June 2, 2015 One... (defun str->num (strin / num) (distof (vl-list->string (vl-remove-if-not '(lambda (x) (or (= x 46) (<= 48 x 57))) (vl-string->list strin) ) ) ) ) (str->num "X: 50.00m") 50.0 _1$ Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 2, 2015 Share Posted June 2, 2015 An old one of mine: Parse Numbers Quote Link to comment Share on other sites More sharing options...
LASSAADTH Posted June 2, 2015 Author Share Posted June 2, 2015 I try both solutions proposed but without success I send you my lsp file: step: 1- get a real PC (the one I want to select the text directly in my file) 2-select the Horizontal and Verticla axis and draw the intersection point 3-choose my points and have the texts with. ********** (defun c:POI (/ P1 x1 y1 D1 Z1 PC ss PO pt P2 x2 y2 D2 Z2) (setq PC (getreal "\nPC\n")) I want to get this value with selecting text in dwg file?? (setq Angle (getvar "AUNITS")) (setvar "AUNITS" 2 ) (if (and (setq ss (ssget '((0 . "LINE,LWPOLYLINE")))) (= 2 (sslength ss)) (setq int (vLa-intersectwith (vLax-ename->vLa-Object (ssname ss 0)) (vLax-ename->vLa-Object (ssname ss 1)) acextendnone ) ) (setq PO (vLax-safearray->List (vLax-variant-vaLue int))) ) (repeat (/ (length PO) 3) (setq pt (list (car PO) (cadr PO) (caddr PO))) (command "_.POINT" pt) ) ) (while ; SELECTION A (setq P1 (getpoint "\Point A: ")) (setq x1 (rtos (- (car P1) (car PO)) 2 2)) (setq y1 (rtos (+ (- (cadr P1) (cadr PO)) PC) 2 3)) (setq D1 (strcat x1)) (setq Z1 (strcat y1)) (command "_MTEXT" P1 "H" 0.34 "L" 20 D1 "") (command "_MTEXT" P1 "R" 100 "H" 0.34 "L" 20 Z1 "") ; SELECTION B (setq P2 (getpoint "\Point B: ")) (setq x2 (rtos (- (car P2) (car PO)) 2 2)) (setq y2 (rtos (+ (- (cadr P2) (cadr PO)) PC) 2 3)) (setq D2 (strcat x2)) (setq Z2 (strcat y2)) (command "_MTEXT" P2 "H" 0.34 "L" 20 D2 "") (command "_MTEXT" P2 "R" 100 "H" 0.34 "L" 20 Z2 "") ) ) *************** Thank you for helping me. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 3, 2015 Share Posted June 3, 2015 I use lee's parse numbers no problems works great (setq test "test string 123") (car (LM:parsenumbers test)) ; answer is returned as a list with one value ;returns 123 Quote Link to comment Share on other sites More sharing options...
LASSAADTH Posted June 8, 2015 Author Share Posted June 8, 2015 How can I do? Help please! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 9, 2015 Share Posted June 9, 2015 You must copy Lee's Parse into your code ; did TEXT asdf 123 hjk (setq obj (vlax-ename->vla-object (car (entsel)))) ; picked the text (setq txtstr (vla-get-textstring obj)) (car (LM:parsenumbers txtstr)) ; answer is returned as a list with one value ;returns 123 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.