TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on February 01, 2021, 08:53:57 AM
-
Hi.I have 4 different words (multy times in the same drawing) in layer with name KYROSI. This words are (AA, DA, PA, AD). I am searching for a lisp to select all
1) AA text and move them to layer TEXT-AA
2) DA text and move them to layer TEXT-DA
3) PA text and move them to layer TEXT-PA
4) AD text and move them to layer TEXT-AD
use (command "_.-style" "_MYTEXTSTYLE" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
Thanks
-
Just use a ssget Text make a selection set of text, then use wcmatch to look for "AA" etc you will need to repeat searching the selection for each "Word"
-
Quick one -
(defun c:txt2lay
( / i l s x
) (setq l '
("AA" "DA" "PA" "AD")) )
)
)
)
-
Thanks Lee Mac. Can you update the code to work from Mtext and change the selected text color to bylayer?
Thanks
-
I try to change the code to this
(defun c:txt2lay
( / i l s x
) (setq l '
("AA" "DA" "PA" "AD")) )
)
)
)
but is not working for mtext . Any options?
-
I try to change the code to this but is not working. Why?
(defun c:txt2lay
( / i l s x
) (setq l '
("AA" "DA" "PA" "AD")) )
)
)
)
Thanks
-
Your MText may contain formatting codes embedded within the text content.
-
Hi lee . I upload a photo with the text properties. I attach and the dxf file. The mtext are in greek language. I export this dxf from QGIS (if it helps).
Thanks
-
The simplest way is to pick the mtext, get the string then use lee's unformat this will return the greek text. So you could make a While that selects the mtext etc strips it and makes the List L to use in the code.
(setq l '())
(while (setq ent (entsel "\Pick a text Enter to exit"))
(setq str (cdr (assoc 1 (entget (car ent)))))
(setq nstr (LM:unformat str nil))
(setq L (cons nstr L))
)
Did notice because of the dxf the layers do not exist so code needs a make layer check also or just make it, if it exists it will continue ok.
-
Hi Bigal. Can you help with this change?
Thanks
-
This needs to be changed (cdr (assoc 1 x)) returns the text including the mtext formatting so need to (setq nstr (LM:unformat (cdr (assoc 1 x)) nil)) then (strcat "TEXT - " nstr)