Jump to content

Changing the text and mtext by operating on the selected text and mtext


thecocuk07

Recommended Posts

hello  , 

 

I am sorry for my English 

 

Is there a lisp that can do something like the picture? 

 

Changing the text and mtext by operating on the selected text and mtext

 

-Metric numbers in text and mtext     example  ; 10.025  , -10.025       (n)

 

-  add or subtract with the desired number       (x) 

 

-  results can be millimetric (no decimal) and + - symbol       =

 

 

n - x  or n +x    =   + y or  -y 

 

10.025   -10.000   =   +25

 

-10.025  +10.000   =  -25 

 

asbuilt_text_mtext.JPG

asbuilt_text_mtext_2.JPG

Link to comment
Share on other sites

As name implies -ve is ok.

 

; Adds a fixed amount to a number
; By Alan H

(Alert "TO USE JUST TYPE A2L or A2LM for multiple ")


;(setvar "cmdecho" 1)
(setq olddimzin (getvar "Dimzin"))
(setvar "dimzin" 0)

(DEFUN c:A2L ( / test en1 v1 a b el en1)
(if (not AH:getvalsm)(load "Multi Getvals"))
(setq v2 (Atof (nth 0 (AH:getvalsm (list "Add to levels" "Enter amount" 10 9 "1")))))

(setq test 1)
(while (= test 1)
      (setq en1 (car (entsel "\nSelect text number:" )))
       (if (/= en1 nil)
        (progn
        (setq el1 (entget en1))
        (setq v1 (atof (cdr (assoc 1 el1))))
        (setq a (+ v1 v2))
        (setq b (rtos a 2 3))
        (setq el (subst (cons 1 b) (assoc 1 el1) el1))
        (entmod el)
;        (entupd en1)
        );progn
       (princ "\nplease pick again"); else
     );if
); while true
(setq el nil)
(setq en nil)
(setq a nil)
(setq v1 nil)

(setvar "cmdecho" 1)
(setvar "dimzin" olddimzin)
(princ)
); END a2l DEFUN

(defun c:A2LM ()
(if (not AH:getvalsm)(load "Multi Getvals"))
(setq v2 (Atof (nth 0 (AH:getvalsm (list "Add to levels" "Enter amount" 10 9 "1")))))
(setq ss (ssget (list (cons 0 "Text"))))
(setq len (sslength ss))
(setq x 0)

(repeat len
(setq en1 (ssname ss x))
        (setq el1 (entget en1))
        (setq v1 (atof (cdr (assoc 1 el1))))
        (setq a (+ v1 v2))
        (setq b (rtos a 2 3))
        (setq el (subst (cons 1 b) (assoc 1 el1) el1))
        (entmod el)
(setq x (+ x 1))
); repeat

(setq el nil
      ss nil)
(setq en nil)
(setq a nil)
(setq v1 nil)


(setvar "dimzin" olddimzin)
(setvar "cmdecho" 1)
(princ)

); END a2lm DEFUN

 

Link to comment
Share on other sites

7 hours ago, BIGAL said:

As name implies -ve is ok.

 

; Adds a fixed amount to a number
; By Alan H

(Alert "TO USE JUST TYPE A2L or A2LM for multiple ")


;(setvar "cmdecho" 1)
(setq olddimzin (getvar "Dimzin"))
(setvar "dimzin" 0)

(DEFUN c:A2L ( / test en1 v1 a b el en1)
(if (not AH:getvalsm)(load "Multi Getvals"))
(setq v2 (Atof (nth 0 (AH:getvalsm (list "Add to levels" "Enter amount" 10 9 "1")))))

(setq test 1)
(while (= test 1)
      (setq en1 (car (entsel "\nSelect text number:" )))
       (if (/= en1 nil)
        (progn
        (setq el1 (entget en1))
        (setq v1 (atof (cdr (assoc 1 el1))))
        (setq a (+ v1 v2))
        (setq b (rtos a 2 3))
        (setq el (subst (cons 1 b) (assoc 1 el1) el1))
        (entmod el)
;        (entupd en1)
        );progn
       (princ "\nplease pick again"); else
     );if
); while true
(setq el nil)
(setq en nil)
(setq a nil)
(setq v1 nil)

(setvar "cmdecho" 1)
(setvar "dimzin" olddimzin)
(princ)
); END a2l DEFUN

(defun c:A2LM ()
(if (not AH:getvalsm)(load "Multi Getvals"))
(setq v2 (Atof (nth 0 (AH:getvalsm (list "Add to levels" "Enter amount" 10 9 "1")))))
(setq ss (ssget (list (cons 0 "Text"))))
(setq len (sslength ss))
(setq x 0)

(repeat len
(setq en1 (ssname ss x))
        (setq el1 (entget en1))
        (setq v1 (atof (cdr (assoc 1 el1))))
        (setq a (+ v1 v2))
        (setq b (rtos a 2 3))
        (setq el (subst (cons 1 b) (assoc 1 el1) el1))
        (entmod el)
(setq x (+ x 1))
); repeat

(setq el nil
      ss nil)
(setq en nil)
(setq a nil)
(setq v1 nil)


(setvar "dimzin" olddimzin)
(setvar "cmdecho" 1)
(princ)

); END a2lm DEFUN

 

thank you  ,  

Multi GETVALS.lsp     works with lisp   ....  

 

the result     for example    -0.005  or   0.005     ,,,     for these results to be like this    -5  or  +5 (with the + icon)      

 

what do i need to change in lisp ?

 

 

 

https://www.cadtutor.net/forum/topic/68861-lego-blocks/

 

Multi GETVALS.lsp

Edited by thecocuk07
Link to comment
Share on other sites

10 hours ago, mhupp said:

 

thank you  , 

 

i have looked at this. but it deletes the decimal places    ... +0.010    > 0.01                   what i want    +0.010 >>   +10 

Link to comment
Share on other sites

2 hours ago, mhupp said:

Ah that's my bad thought these where the same.

https://cadtips.cadalyst.com/notestext/run-calculations-numerical-text-and-mtext

 

Allows you to pick how many decimal places you want. do your original math ± 8.400. Then you have to run again and multiple by 1000 to get  +0.010 >>   +10 

 

 

 

 

thank you  ,  

 

yes almost met my needs   ,,,  

 

 

what to change to have + symbol at the start of positive results

Edited by thecocuk07
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...