ayman Posted April 8, 2010 Posted April 8, 2010 hi there please i want lisp subtracting number from number and ask me where to insert the result thank's very much Quote
Lee Mac Posted April 8, 2010 Posted April 8, 2010 Would you be selecting these numbers from the drawing? Quote
Lee Mac Posted April 8, 2010 Posted April 8, 2010 Try this: (defun c:subtxt (/ ParseNumbers GR NUM1 NUM2 P RES) (vl-load-com) ;; Lee Mac ~ 09.04.10 (defun ParseNumbers (str / lst Num Aph x rtn) ;; Lee Mac ~ 20.09.09 (setq lst (vl-string->list str) Num "" Aph "") (while (setq x (car lst)) (setq lst (cdr lst)) (cond ( (and (/= "" Num) (= 46 x)) (setq Num (strcat Num (chr x)))) ( (< 47 x 58) (setq Num (strcat Num (chr x)) rtn (cons Aph rtn) Aph "")) (t (setq Aph (strcat Aph (chr x)) rtn (cons (read Num) rtn) Num "")))) (vl-remove nil (vl-remove "" (reverse (cons Aph (cons (read Num) rtn)))))) (mapcar (function (lambda (sym str / ent) (while (progn (setq ent (car (nentsel str))) (cond ( (eq 'ENAME (type ent)) (if (wcmatch (cdr (assoc 0 (entget ent))) "*TEXT") (if (not (set sym (car (vl-remove-if-not (function (lambda (x) (vl-position (type x) '(INT REAL)))) (ParseNumbers (cdr (assoc 1 (entget ent)))))))) (princ "\n** Text Must Contain a Number **")) (princ "\n** Object Must be Text **"))) ( (princ "\n** Nothing Selected **"))))))) '(num1 num2) '("\nSelect Text to Subtract from: " "\nSelect Text to Subtract: ")) (if (and num1 num2 (setq res (entmakex (list (cons 0 "TEXT") (cons 10 (getvar 'VIEWCTR)) (cons 40 (getvar 'TEXTSIZE)) (cons 7 (getvar 'TEXTSTYLE)) (cons 1 (rtos (- num1 num2)))))) (setq res (entget res))) (while (and (= 5 (car (setq gr (grread 't 13 0)))) (listp (setq p (cadr gr)))) (entupd (cdr (assoc -1 (setq res (entmod (subst (cons 10 p) (assoc 10 res) res)))))))) (princ)) Quote
ayman Posted April 9, 2010 Author Posted April 9, 2010 lee mac thank you very much you are so kind that was wat i want but i want the result rotated at 90 degree and precision 2 like this 3.52 and make it multiple because i have too much number thanks again Quote
Lee Mac Posted April 9, 2010 Posted April 9, 2010 Try this: (defun c:subtxt (/ ParseNumbers GR NUM1 NUM2 P RES) (vl-load-com) ;; Lee Mac ~ 09.04.10 (defun ParseNumbers (str / lst Num Aph x rtn) ;; Lee Mac ~ 20.09.09 (setq lst (vl-string->list str) Num "" Aph "") (while (setq x (car lst)) (setq lst (cdr lst)) (cond ( (and (/= "" Num) (= 46 x)) (setq Num (strcat Num (chr x)))) ( (< 47 x 58) (setq Num (strcat Num (chr x)) rtn (cons Aph rtn) Aph "")) (t (setq Aph (strcat Aph (chr x)) rtn (cons (read Num) rtn) Num "")))) (vl-remove nil (vl-remove "" (reverse (cons Aph (cons (read Num) rtn)))))) (mapcar (function (lambda (sym str / ent) (while (progn (setq ent (car (nentsel str))) (cond ( (eq 'ENAME (type ent)) (if (wcmatch (cdr (assoc 0 (entget ent))) "*TEXT") (if (not (set sym (car (vl-remove-if-not (function (lambda (x) (vl-position (type x) '(INT REAL)))) (ParseNumbers (cdr (assoc 1 (entget ent)))))))) (princ "\n** Text Must Contain a Number **")) (princ "\n** Object Must be Text **"))) ( (princ "\n** Nothing Selected **"))))))) '(num1 num2) '("\nSelect Text to Subtract from: " "\nSelect Text to Subtract: ")) (if (and num1 num2 (setq res (entmakex (list (cons 0 "TEXT") (cons 10 (getvar 'VIEWCTR)) (cons 40 (getvar 'TEXTSIZE)) (cons 7 (getvar 'TEXTSTYLE)) (cons 50 (/ pi 2)) (cons 1 (rtos (- num1 num2) (getvar 'LUNITS) 2))))) (setq res (entget res))) (while (and (= 5 (car (setq gr (grread 't 13 0)))) (listp (setq p (cadr gr)))) (entupd (cdr (assoc -1 (setq res (entmod (subst (cons 10 p) (assoc 10 res) res)))))))) (princ)) Quote
ayman Posted April 9, 2010 Author Posted April 9, 2010 lee mac that was exact what i want you make me happy than;'s alot Quote
Lee Mac Posted April 9, 2010 Posted April 9, 2010 lee mac that was exact what i want you make me happy than;'s alot No worries mate Quote
ayman Posted April 9, 2010 Author Posted April 9, 2010 lee mac ther's small thing i want when i call the lisp and when he ask me for selecting text to subtract from i want to select many number not just one ant when i hit enter it ask me to select Text to Subtract ant when i hit enter it give me the result and this image will exlanin what i want thank's lee for help Quote
Lee Mac Posted April 9, 2010 Posted April 9, 2010 That's not such an easy fix - it would mean rewriting half the LISP, is it too much to click each pair? Quote
alanjt Posted April 9, 2010 Posted April 9, 2010 Lee, You inspired me to write an entire new one of these last night. Just put on the finishing touches. CombineValues.LSP Quote
alanjt Posted April 9, 2010 Posted April 9, 2010 Nice one Alan Thanks I'll probably never use it (I haven't used the old one I have in a year or so), but it was fun to write. Quote
ayman Posted April 10, 2010 Author Posted April 10, 2010 lee mac firest of all thank's for help the secend is i have too much to click pair because i have too much pairs so if u do what i want it will be better and thank's for help man Quote
alanjt Posted April 10, 2010 Posted April 10, 2010 lee mac firest of all thank's for help the secend is i have too much to click pair because i have too much pairs so if u do what i want it will be better and thank's for help man Consider how much work you would have without what was provided to you, for free. Quote
ketxu Posted October 22, 2010 Posted October 22, 2010 I can't download this lisp.In link topic,link to download not show Quote
Shaheensha976 Posted June 24, 2020 Posted June 24, 2020 On 4/9/2010 at 3:25 PM, Lee Mac said: (defun c:subtxt (/ ParseNumbers GR NUM1 NUM2 P RES) (vl-load-com) ;; Lee Mac ~ 09.04.10 (defun ParseNumbers (str / lst Num Aph x rtn) ;; Lee Mac ~ 20.09.09 (setq lst (vl-string->list str) Num "" Aph "") (while (setq x (car lst)) (setq lst (cdr lst)) (cond ( (and (/= "" Num) (= 46 x)) (setq Num (strcat Num (chr x)))) ( (< 47 x 58) (setq Num (strcat Num (chr x)) rtn (cons Aph rtn) Aph "")) (t (setq Aph (strcat Aph (chr x)) rtn (cons (read Num) rtn) Num "")))) (vl-remove nil (vl-remove "" (reverse (cons Aph (cons (read Num) rtn)))))) (mapcar (function (lambda (sym str / ent) (while (progn (setq ent (car (nentsel str))) (cond ( (eq 'ENAME (type ent)) (if (wcmatch (cdr (assoc 0 (entget ent))) "*TEXT") (if (not (set sym (car (vl-remove-if-not (function (lambda (x) (vl-position (type x) '(INT REAL)))) (ParseNumbers (cdr (assoc 1 (entget ent)))))))) (princ "\n** Text Must Contain a Number **")) (princ "\n** Object Must be Text **"))) ( (princ "\n** Nothing Selected **"))))))) '(num1 num2) '("\nSelect Text to Subtract from: " "\nSelect Text to Subtract: ")) (if (and num1 num2 (setq res (entmakex (list (cons 0 "TEXT") (cons 10 (getvar 'VIEWCTR)) (cons 40 (getvar 'TEXTSIZE)) (cons 7 (getvar 'TEXTSTYLE)) (cons 50 (/ pi 2)) (cons 1 (rtos (- num1 num2) (getvar 'LUNITS) 2))))) (setq res (entget res))) (while (and (= 5 (car (setq gr (grread 't 13 0)))) (listp (setq p (cadr gr)))) (entupd (cdr (assoc -1 (setq res (entmod (subst (cons 10 p) (assoc 10 res) res)))))))) (princ)) Quote
Shaheensha976 Posted June 24, 2020 Posted June 24, 2020 this lisp how to place the value in end point Quote
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.