Hello, We are using autocad 2012.
Is there a way to move all 3.5mm text to layer text3.5 and move all 5mm text to layer text5.
I was hoping in a lisp rather than Qselect.
Any pointer would be great.
Regards
Warren.
Try this
(defun C:TEST ( / dmz lay e l) (setq dmz (getvar 'dimzin) lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) ) (setvar 'dimzin 8) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l (strcat "text" (rtos (vla-get-height e) 2))) (if (not (tblsearch "Layer" l)) (vla-Add lay l)) (vla-put-Layer e l) ) ) (setvar 'dimzin dmz) (princ) )
@warrentdo wrote:
Is there a way to move all 3.5mm text to layer text3.5 and move all 5mm text to layer text5.
another
(defun c:test2 (/ ss f on ob) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (repeat (sslength ss) (if (setq f (assoc (cdr (assoc 40 (setq on (entget (setq ob (ssname ss 0)))) ) ) '((3.5 "Text3.5")(5.0 "Text5.0")))) (entmod (subst (cons 8 (cadr f)) (assoc 8 on) on) ) ) (ssdel ob ss) )(princ) )
we may need to add a fuzz value in case where the text height is NOT exactly 3.5 (i.e. 3.502)
HTH
with fuzz
(defun c:test3 (/ ss f on ob lay) (setq ss (ssget '((0 . "TEXT,MTEXT")))) (repeat (sslength ss) (setq f (cdr (assoc 40 (setq on (entget (setq ob (ssname ss 0)))) ))) (if (setq lay (cond ((equal f 3.5 0.01) "Text3.5") ((equal f 5.0 0.01) "Text5.0"))) (entmod (subst (cons 8 lay) (assoc 8 on) on) ) ) (ssdel ob ss) )(princ) )
usage:
command: Test3
HTH
Hello Phanaem and thank you for your help.
Ive had a play and just changed l (strcat "0-" (rtos (vla-get-height e) 2)"TEXT"))
Bow Ive forgot something. this would create a layer 0-3.5text and what I have to create is 0-35text.
All this becasue of a decimal point!! Client requirement.
I love the lisp though.
Cheers
Thats the one.
(defun c:movetextfuzz (/ ss f on ob lay)
(setq ss (ssget '((0 . "TEXT,MTEXT"))))
(repeat (sslength ss)
(setq f (cdr
(assoc 40
(setq on (entget (setq ob (ssname ss 0))))
)))
(if (setq lay
(cond
((equal f 3.5 0.01) "0-35TEXT")
((equal f 5.0 0.01) "0-50TEXT")))
((equal f 7.0 0.01) "0-70TEXT")))
(entmod (subst (cons 8 lay) (assoc 8 on) on)
)
)
(ssdel ob ss)
)(princ)
)
Cheers all.
Regards
Warren.
@warrentdo wrote:....
Is there a way to move all 3.5mm text to layer text3.5 and move all 5mm text to layer text5.
....
If such Text is put into the drawing by some kind of routine or menu item, or is in a Style that has a fixed height, I would think the fuzz factor would not be needed. What's going to make a piece of Text come out with a height of 3.502? It's not like checking the length of a Line or something. If in fact the fuzz factor isn't needed, it can be quite simple:
(command
"_.chprop" (ssget "X" '((0 . "TEXT") (40 . 3.5))) "" "_layer" "text3.5" ""
"_.chprop" (ssget "X" '((0 . "TEXT") (40 . 5.0))) "" "_layer" "text5" ""
)
Hi all,
I tried to butcher the lisps provided to suit my own requirements, but have failed miserably...
Rather than searching for a specfic height value, I tried to make the lisp ask me for a content variable.
I have a survey dwg with hundreds of spot levels. I'd like to put all text with content "123.84" onto a layer of the same name.
Although I could amend the lisp to search for all text of 123.96 through to 124.10, I was hoping to make it a useful tool for the future.
Either a lisp that put all text onto a corresponding layer (although this would mean that notes went into layers called "do not scale from this drawing" etc.)
...or a lisp that asked me for the content I'd like (123.84), selected all text with that content, and put it onto a layer of the same name.
Am I barking up the wrong tree, or could your previous lisp solutions be tweaked to serve my purpose?
Many thanks!
Rob
@robchapman82 wrote:Hi all,
.........
...or a lisp that asked me for the content I'd like (123.84), selected all text with that content, and put it onto a layer of the same name.
Am I barking up the wrong tree, or could your previous lisp solutions be tweaked to serve my purpose?
Many thanks!
Rob
a simple code could be
(defun c:Tolayer ( / num ss i e l) (while (not (progn (setq num (getstring "\nEnter value to search: ")) (if (numberp (read num)) num (and (princ "\n<Invalid number>") nil))))) (if (setq ss (ssget "_X" (list '(0 . "TEXT")(cons 1 (strcat "*" num "*"))))) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i)))) l (assoc -1 e)) (entmod (list (cons 8 num) l)))
(princ "\nValue not found") )(princ) )
O would you rather have the routine select all string with a valid numerical value and use a range between x and x. now it would be fun to write a code to do just that
Is that possible?!
I didn't even know I wanted that... but now it seems like a perfect idea...!
The routine provided worked perfectly. Thanks!
@robchapman82 wrote:Is that possible?!
I didn't even know I wanted that... but now it seems like a perfect idea...!
It is possible, [ i think....] , but it would require a set of condtions to follow. but i'm not saying i'm going to write it now though 😄 . If the need requries it, i'll probably do it just for fun.
@robchapman82 wrote:
The routine provided worked perfectly. Thanks!
You are welcome, Glad it works for you.
Cheers