Jump to content

Is there is a way to translate the text & mtext in cad drawings


adeladel

Recommended Posts

Is there is any lisp or way to translate the text & mtext in cad drawings all text together , I mean if open drawing with spanish text and I can't understanding it is there is a lisp to translate all these text to english or any other languages . 

Edited by adeladel
Link to comment
Share on other sites

A quick look at the AutoCAD help pages suggest that Mechanical 2024 edition has some translation ability, limited to about 20 languages, including Spanish. Note that this is the first Translation in AutoCAD so will be 'basic' the next versions after user feedback will be better.

 

There are third party add-in software packages, probably paid for. These are listed in the help pages.

 

As for LISP, not directly. You'd need to link this to a web host for the translation. A simpler method, not as user friendly, might be to copy the text to the clipboard (LISP can do this), and manually paste into a web translation service, copy the result and then paste back into the text. LISP can help with the copy original text and paste translated text. If using a web based translation service they might not have all the technical terms, abbreviations and so on that we use so would need checking.

  • Like 1
Link to comment
Share on other sites

thanks for your help, I appreciate your time and effort to replying to this topic , I believe in the future the translation will be in cad command, thanks again and have a good time.

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

I have used a tool that was around $39-$59 if I recall, to extract the text items and translate them with machine translation and then re-unite. The process can be used for translating the DXF file in mere minutes even if you don't have access to AutoCAD. I'll try to find the tool. It's also the one mentioned in MemoQ for DXF format. For human translation that works, of course, but I used it in a more automated high-volume project (thousands of files)

 

Link to comment
Share on other sites

here is what may help:  https://www.translationtospanish.com/cad/documentation.htm

 

In essence it is used to split a file into two, where one has the text items that should be translated and the other has the rest. After translating you use the same tool to re-unite the two in the same sequence but now with translated content. How you do the translation has many options, human in that text file, in CAT tools, or with machine translation.

 

Just beware of the encoding. Some MT tools will return as UTF-8, but in my experience the file needed to be in original Windows encoding, the way it came out from the splitting. It's easy to re-encode it, I used Notepad++ in my tests. Not sure how the customer ended up doing it, but it worked. (this was a a large aerospace company where they needed to translate to English - can't say more).

 

Hope this helps. Feel free to ping me if you need more guidance.

 

 

 

 

 

Link to comment
Share on other sites

Looks like advertising to me.

 

I have already posted links to FREE AutoCAD apps that do everything directly in AutoCAD.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Yes, there is a way to translate text and mtext (multi-line text) in CAD drawings. AutoCAD and other CAD software offer several methods to translate text within your drawings:

1. Manual Translation:

You can manually select and edit each text or mtext object within the drawing to translate it into the desired language. While this method is time-consuming for large drawings, it allows for precise control over the translation.

2. Find and Replace:

AutoCAD’s Find and Replace feature allows you to search for specific words or phrases in your drawing and replace them with translated versions. This can be useful for repetitive text that appears throughout the drawing.

To use this feature:

Press Ctrl + F or type FIND in the command line.

Enter the text you want to replace.

Input the translated version in the Replace With field.

3. Export Text for Translation:

For large projects, it may be more efficient to export the text and mtext to an external file (like an Excel spreadsheet), translate it, and then import it back into the drawing. Some third-party tools and LISP routines can automate this process.

AutoLISP scripts: You can use AutoLISP routines to extract all text or mtext in the drawing, translate it using an external translation service (like Google Translate), and then import it back into the drawing.

4. Translation Software or Plugins:

There are CAD plugins and translation software specifically designed to help with translating text in drawings. Some of these tools automate the process of extracting text, translating it, and reinserting the translated text back into the drawing.

5. Use Online Translation Services:

You can copy the text from the drawing, translate it using an online service like Google Translate, and then paste the translated text back into the drawing.

These methods allow you to efficiently translate the text in your CAD drawings, depending on the scope and size of your project.

 

Link to comment
Share on other sites

And here is my way:

(defun c:txt_out( / ss file el i)
  (setq file  (open (getfiled "Select OUTput" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname"))) "csv" 1) "w"))
  (setq ss (ssget "X" (list (cons 0 "*TEXT"))))
  (repeat (setq i (sslength ss))
    (write-line (strcat (cdr (assoc 1 (setq el (entget (ssname ss (setq i (1- i))))))) ";" (cdr (assoc 5 el))) file)
    )
  (print "ok")
  (close file)
  )

(defun c:txt_in( / file ss line limit el continue i)
  (setq file  (open (getfiled "Select INput" "" "csv" 4) "r"))
  (setq ss (ssget "X" (list (cons 0 "*TEXT"))))
  (setq line (read-line file))
  (while line
    (setq limit (vl-string-search ";" line) txt (substr line 1 limit) hand (substr line (+ 2 limit)))
    (setq continue T i (sslength ss))
    (while continue
      (setq el (entget (ssname ss (setq i (1- i))))
	    continue (not (= hand (cdr (assoc 5 el))))
	    )
      )
    (entmod (subst (cons 1 txt) (assoc 1 el) el))
    (setq line (read-line file))
    )
  (close file)
  )

Usage:

First of all, make a safety-copy of the drawing. Load these Lisp routines and use the TXT_OUT to get all the texts in a CSV file. The drawing file must remain open, don't edit it any more!!!!!

Open that CSV in Excel and translate the first column. Use online translators or so... I used to pass the CSV file to a nice lady in the neighbor office to translate it for me. Edit only the first column in the CSV document!

Save the changes and return to AutoCAD. Start the 2nd Lisp TXT_IN and point the CSV file you just saved. The Lisp should do the rest for you.

  • Like 1
Link to comment
Share on other sites

From here: https://stackoverflow.com/questions/19098260/translate-text-using-vba

 

If you can copy to excel then this might be the start of a macro to translate - not something I've ever needed to do but can LISP run an excel macro?

 

(excel macro, not LISP below)

 

Function Translate$(sText$, FromLang$, ToLang$)
    Dim p1&, p2&, url$, resp$
    Const DIV_RESULT$ = "<div class=""result-container"">"
    Const URL_TEMPLATE$ = "https://translate.google.com/m?hl=[from]&sl=[from]&tl=[to]&ie=UTF-8&prev=_m&q="
    url = URL_TEMPLATE & WorksheetFunction.EncodeURL(sText)
    url = Replace(url, "[to]", ToLang)
    url = Replace(url, "[from]", FromLang)
    resp = WorksheetFunction.WebService(url)
    p1 = InStr(resp, DIV_RESULT)
    If p1 Then
        p1 = p1 + Len(DIV_RESULT)
        p2 = InStr(p1, resp, "</div>")
        Translate = Mid$(resp, p1, p2 - p1)
    End If
End Function


=Translate(A1, "en", "fr")    '<--translates text in A1 from English to French.

 

URL = "https://translate.google.com/#" & langFrom & "/" & langTo & "/" & Text

appears to be the key to this for google translate but I also think that free translate is limited to the number of text strings you can do daily.

 

 

If you can extract the result from the webpage you could do it directly?

....https://translate.google.com/?sl=auto&tl=fr&text=Hello&op=translate

Edited by Steven P
  • Like 1
Link to comment
Share on other sites

@Steven P nice idea thinking post value to A1 and call the VBA macro in Excel, then read the cell B1.

 

Can you post a working excel with macros set up please.

 

Ok found some help

 

Press Alt+F11 to open the Visual Basic Editor (on the Mac, press FN+ALT+F11), and then click Insert > Module. A new module window appears on the right-hand side of the Visual Basic Editor.

Copy and paste the following code to the new module.

 

The =Translate(A1, "en", "fr") should now work. Convert to French.

 

Ok a bit of lisp, I do know the translate has a character limit.

 

(defun c:translate ( / myxl obj txt myrange)

(or (setq myxl (vlax-get-object "Excel.Application"))
    (setq myxl (vlax-get-or-create-object "excel.Application"))
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(while (setq txtent (car (entsel "\nSelect a text Enter to exit ")))
 (setq obj (vlax-ename->vla-object txtent))
 (setq txt (vlax-get obj 'Textstring))
 
 (setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" "A1"))
 (vlax-put-property myRange 'Value2 txt)
 
 (setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" "B1"))
 (vlax-put obj 'Textstring (vlax-variant-value (vlax-get-property myRange 'Value2)))
)
(if (not (vlax-object-released-p myRange))(progn(vlax-release-object myRange)(setq myRange nil)))
(if (not (vlax-object-released-p myXL))(progn(vlax-release-object myXL)(setq myXL nil)))

(princ)
)
(c:translate)

 

How to use big thanks @Steven P open excel and make the function, yes save the  blank Excel for future use. Put the =Translate(A1, "en", "fr") in cell B1.

 

Just select text BIG BUT only use single line text at moment maybe a mtext version later. I copied the text for testing. You should see in Excel the A1 cell changing same with B1 to new language.

 

Theoretically could select multi text in one go and watch it change. Replace while with a selection set.

 

One question to Steven how did you find the "fr" for French ? Sort of found a way to work out the id. "gn" german ? "it" Italian ?

 

 

 

 

Edited by BIGAL
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...