mohammadreza Posted April 15 Posted April 15 hello everybody i need to change letter "ی" in Arabic language to letter"d" in English. i tried to change Entity group number (1 . "ی") but i failed .please help me. its lisp that i used. (defun c:ReplaceYInAllTexts ( / ss i ent entData txt newtxt) (princ "\nProcessing all text entities...") ;; Select all TEXT and MTEXT entities in the drawing (setq ss (ssget '((0 . "TEXT,MTEXT")))) (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (ssname ss i)) ; Get entity from selection set (setq entData (entget ent)) ; Get DXF data of entity (setq txt (cdr (assoc 1 entData))) ; Get the text string ;; Replace both Persian and Arabic "ی"/"ي" with "d" (setq newtxt (vl-string-translate "يی" "dd" txt)) (if (/= txt newtxt) ; If text was changed (progn (setq entData (subst (cons 1 newtxt) (assoc 1 entData) entData)) ; Replace text (entmod entData) ; Modify the entity (entupd ent) ; Update the display ) ) (setq i (1+ i)) ; Go to next entity ) (princ "\n All text entities processed and updated where needed.") ) (princ "\n No text entities found.") ) (princ) ) Quote
GLAVCVS Posted April 15 Posted April 15 Hi @Mohammedreza If '...-translate' doesn't work as expected, try '...-subst' And if that doesn't work either, convert the string to a list with 'vl-string->list' and replace the integer with the one that corresponds to the ASCII of the target character. After that, convert the resulting list again with 'vl-list->string' 1 Quote
Saxlle Posted April 15 Posted April 15 Hi @mohammadreza, Maybe you need tou use Unicode characters to replace the letter "ي" (if you look at Unicode character list Arabic, you will se the letter "ي" have "U+064A"). This is the Unicode characters for Basic Latin (letter d = U+0064). So, if I use this (if you have only one letter): (setq ent (entget (car (entsel "\nSelect TEXT or MTEXT:")))) txt (cdr (assoc 1 ent)) ) From "txt" variable I get "\U+064A" which represent the letter "ي" and, if you want to substitue the letter "ي" with letter "d", use the next line of code (entmod (subst (cons 1 "\U+0064") (cons 1 txt) ent)) where "\U+0064" represent the letter "d" I get the desired output. Also, if you have something like this "{\\fArial|b0|i0|c178|p34;\U+064A} {\\fArial|b0|i0|c178|p34;\U+064A}", use this Lee Mac UnFormat String to clean everything and get "\U+064A \U+064A". To do this, you need first to clean string to get "\U+064A \U+064A", then replace old string (for e.g. "{\\fArial|b0|i0|c178|p34;\U+064A} {\\fArial|b0|i0|c178|p34;\U+064A}") with "\U+064A \U+064A" using (entmod (subst ....), then again get data about entity, use "\U+0064 \U+0064" to substitue "\U+064A \U+064A". I know it's confusing, but you need to try it on your own. Best regards. 1 Quote
hosneyalaa Posted April 15 Posted April 15 5 hours ago, mohammadreza said: i need to change letter "ی" in Arabic language to letter"d" in English. i tried to change Entity group number (1 . "ی") but i failed .please help me. Can you attach an example drawing? Quote
Steven P Posted April 15 Posted April 15 Try this: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-and-replace-text/td-p/5649883 Though the usual 'find' command should do this as well 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.