Jump to content

Recommended Posts

Posted

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)
)

 

Posted

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'

  • Like 1
Posted

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.

  • Like 1
Posted
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?

 

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...