Jump to content

Recommended Posts

Posted

Please tell me the correct translation of variables in the code, because my translation doesn't work...
At least the basic words:
pozice / delka / znak 
I translate it as:
position / length / symbol

This is part of the code. The full code is in the attachment.

(defun MTEXTCF0	(txr / pozice delka znak ntx)	; vlastni vykonna funkce, prevadi TXR na NTX
  (setq ntx "")
  (setq pozice 1)
  (setq delka (strlen txr))
  (while (<= pozice delka)
    (setq znak (substr txr pozice 1))
    (if	(= znak "\\")			;pokud je lomitko      
      (progn
 (setq pozice (1+ pozice))			; posunu se na dalsi znak
 (setq znak (substr txr pozice 1))
 (if (or (= znak "{") (= znak "}") (= znak "\\") (= znak "P")); bylo druhe lomitko nebo sloz.zavorka? (nebo P - oprava: VM 31.7.2001)
   (setq ntx (strcat ntx "\\" znak))		; ANO -> vysledny znak kopiruji
   (progn					; NE -> ignoruji znaky az do ";"
     (while (and (/= znak ";") (<= pozice delka))
       (setq pozice (1+ pozice))
       (setq znak (substr txr pozice 1))
       )
     )
   )
 )
      (if (and (/= znak "{") (/= znak "}"))		; pokud neni lomitko ... a neni to ani zavorka
 (setq ntx (strcat ntx znak))			; tak pouze kopiruji vstup
 )
      )
    (setq pozice (1+ pozice))
    )
  (setq ntx ntx)
  )

 

mtextcf-Czech.lsp

Posted

You can use Replace command from any text editor to replace all identical words.

  • Thanks 1
Posted
48 minutes ago, Tharwat said:

You can use Replace command from any text editor to replace all identical words.

I know this, I need the correct translation of variables for substitution in the code function,
to make it work properly...

(setq znak (substr txr pozice 1)) 

is that right?:

(setq symbol (substr txr position 1))

 

Posted

So if the LISP works as it is, it will work the same if you replace any variable name with any other.

 

This is using a search engines 'Translate' function, took seconds, but you'll have to perhaps check through it for example to make sure the variables aren't command names (it will still work but a lot easier if they aren't)

 

 

(DeFun MTEXTCF0 (TXR/Position Length NTX Character) ; Own powerful function, converts TXR to NTX
  (setq ntx "")
  (setq position 1)
  (setq length (strlen txr))
  (while (<= position length)
    (setq character (substr txr position 1))
    (if (= character "") ;p if there is a slash      
      (progn
 (setq positions (1+ positions)) ; I'll move on to the next sign
 (setq character (substr txr position 1))
 (if (or (= character "{") (= character "}") (= character "") (= character "P")); Was the second slash or a brace? (or P - correction: VM 31.7.2001)
   (setq ntx (strcat ntx "" character)) ; YES -> copy the resulting character
   (progn ; NO -> ignore characters up to ";"
     (while (and (/= character ";") (<= position length))
       (setq positions (1+ positions))
       (setq character (substr txr position 1))
       )
     )
   )
 )
      (if (and (/= character "{") (/= character "}")) ; if there is no slash ... And it's not even a bracket
 (setq ntx (strcat ntx character)) ; so I just copy the input
 )
      )
    (setq positions (1+ positions))
    )
  (setq ntx ntx)
  )

 

  • Thanks 1
Posted
11 minutes ago, Steven P said:

This is using a search engines 'Translate' function, took seconds, but you'll have to perhaps check through it for example to make sure the variables aren't command names (it will still work but a lot easier if they aren't)

Thanks, but the simple translation doesn't work, I need help with the functions and the corresponding variables.

Posted

Try to translate word "delka" to a word other than "length". "length" is an autolisp function.

  • Thanks 1
Posted

Seems a lot of work compared to maybe "Lee-mac unformat mtext". Do a google next time if you want english versions, there are many good versions out there. 

  • Thanks 1
Posted

Still not sure why you want to translate it if it works (holidays here so CAD is off, I haven't checked it). However I'd go through the above and if you want it translated use the one I posted and the original - global change the variables in the original but using the translated version as a guide, with new variable names to suit.

 

As mentioned above try to avoid variable names that could be the same as command names to avoid confusion, you might for example use TxLen instead of delka and so on (you'll notice in a lot of my LISPs my variables start with 'My' for this reason, MySS, MyEnt and so on).

 

If it still isn't working then just debugging, go through it and comment out all the lines with a ';', take out the ';'s systematically remembering pairs of open and close ( ) for things like if and whole loops to see where the error is

  • Thanks 1
Posted

I have done translations before.

I'd suggest using Notepad ++ to open the file because it keeps the foreign characters for a better translation than regular Notepad.

Then use Google Translate or some other translator and translate the comments only at first. This way you understand what the program is doing.

Then, only translate the prompts. If the program works as it is, I wouldn't tinker with it too much.

Some of the prompts may have some setq variables to adjust, but keep it simple.

  • Like 1
  • Thanks 1
Posted (edited)
10 hours ago, troggarf said:

I have done translations before.

I'd suggest using Notepad ++ to open the file because it keeps the foreign characters for a better translation than regular Notepad.

Then use Google Translate or some other translator and translate the comments only at first. This way you understand what the program is doing.

Then, only translate the prompts. If the program works as it is, I wouldn't tinker with it too much.

Some of the prompts may have some setq variables to adjust, but keep it simple.

I have no difficulty with a simple translation.
I have a problem with the translation of the word "znak".
Character or symbol - it's not right.
The correct translation for this lisp is the word code.
Here is the corrected code that works well.

;;; program MTEXTCF.LSP   (c) 12.4.1999 Jan Bastecky
;;;============================================================================
;;; MTextCleanFormat - odstrani formatovani z MTEXTU - removes MTEXT formatting
;;; modifikace na koty plus upravy, 24.1.2001 + 6.6.2011 CAD Studio
;;; modifikace na dlouhe MTexty 2024 - ARKANCE
;;; English translation 12.2024
(defun MTEXTCF0	(txr / position length code ntx)
  (setq ntx "")
 (setq position 1)
 (setq length (strlen txr))
 (while (<= position length)
    (setq code (substr txr position 1))
   (if	(= code "\\")  
      (progn
 (setq position (1+ position))
 (setq code (substr txr position 1))
(if (or (= code "{") (= code "}") (= code "\\") (= code "P"))
  (setq ntx (strcat ntx "\\" code))
   (progn					
     (while (and (/= code ";") (<= position length))
      (setq position (1+ position))
     (setq code (substr txr position 1))
       )
     )
   )
 )
      (if (and (/= code "{") (/= code "}"))
 (setq ntx (strcat ntx code))
 )
      )
   (setq position (1+ position))
    )
  (setq ntx ntx)
  )

;;;============================================================================
;;; MTextCleanFormat - odstrani formatovani z MTEXTU - nova verze, dlouhe texty
;;;
(defun c:MTEXTCF (/ ss1 cnt ent en txr ntx isOver)
  (vl-load-com)
  (setq ss1 (ssget '((-4 . "<OR")(0 . "MTEXT")(0 . "DIMENSION")(0 . "MULTILEADER")(-4 . "OR>"))))			; vybereme MTEXTy a DIMy
  (if (null ss1)					; vybralo se neco?
    (progn
      (princ "nevybral jste zadny MTEXT (no MTEXT in selection)")
      (quit)
      )
    )

  (setq cnt 0)
  (repeat (sslength ss1)				; cyklus pres vyberovou mno inu
    (setq en (entget (setq ent (ssname ss1 cnt))))			; nactu entitu
	(if (setq isOver (= (cdr (assoc 0 en)) "DIMENSION"))
     (setq txr (vlax-get (vlax-ename->vla-object ent) 'TextOverride))	; vypreparuju text
     (setq txr (vlax-get (vlax-ename->vla-object ent) 'TextString))		; vypreparuju text (MText+MLeader = TextString, Dim = TextOverride)
	);if
    (setq ntx (mtextcf0 txr))				; provedu vlastni konverzi
    (if	(/= txr ntx)					; pokud se text zmenil
	 (if isOver
	  (vlax-put (vlax-ename->vla-object ent) 'TextOverride ntx)		; -> tak ho vymenim ve vykresove databazi
      (vlax-put (vlax-ename->vla-object ent) 'TextString ntx)		; -> tak ho vymenim ve vykresove databazi
	 );if
    )
    (setq cnt (1+ cnt))					; posunu se na dalsi entitu
    )
  (princ)
  )

;;; end of file

I asked about it myself and answered it myself...😛

Edited by Nikon

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