Author Topic: Retrieving Greek characters from Text objects  (Read 1324 times)

0 Members and 1 Guest are viewing this topic.

iliekater

  • Mosquito
  • Posts: 9
Retrieving Greek characters from Text objects
« on: November 02, 2021, 07:35:50 AM »
I am trying to retrieve the text from some Text objects (single line texts) . My code seems to work fine , but when I'm doing this on texts that contain Greek characters , the retrieved text contains wrong characters in the position on the Greek ones . For Example , a "Γ1" text is retrieved as "a1" .
If it's useful , this is the code I am using :
Code: [Select]
  ( setq TextObjectFor_Name ( car ( entsel ) ) )
  ( setq vobject ( vlax-ename->vla-object TextObjectFor_Name ) )
  ( setq ActualString ( vla-get-textstring vobject ) )

mhupp

  • Bull Frog
  • Posts: 250
Re: Retrieving Greek characters from Text objects
« Reply #1 on: November 02, 2021, 02:23:31 PM »
Use vl-string-translate

Code: [Select]
(setq vobject (vlax-ename->vla-object (car (entsel"\nSelect Text"))))
(setq ActualString (vla-get-textstring vobject))
(setq ActualString (vl-string-translate "abcdefghijklmnopqrstuvwxyz" "Γand other greek letters" ActualString))

Set a text with all the greek letters. use the vla-get-textstring on them and have it output to see what came though.
ignore the greek letters that made it thought without changing. add the letters that changed to first and then the greek letters 2nd. The source-set and dest-set need to be the same length

(vl-string-translate "ABCD" "1234" "ABCD_ABCDDDDABCD_ABCDCCC")
;; Returns "1234_12344441234_1234333"

--Edit---
 tho this would turn any A into Γ
 
« Last Edit: November 02, 2021, 02:29:42 PM by mhupp »

mhupp

  • Bull Frog
  • Posts: 250
Re: Retrieving Greek characters from Text objects
« Reply #2 on: November 02, 2021, 02:43:33 PM »
maybe try not non visual lisp way

Code: [Select]
(defun C:TEST (/ vobject ActualString)
  (Setq txt (car (entsel "\nSelect Text:")))
  (if (eq (cdr (assoc 0 (entget txt))) "TEXT")
    (setq ActualString (cdr (assoc 1 (entget e))))
    (prompt "\nThis Isnt Text")
  )
  (princ)
)

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Retrieving Greek characters from Text objects
« Reply #3 on: November 02, 2021, 03:15:56 PM »
but when I'm doing this on texts that contain Greek characters , the retrieved text contains wrong characters in the position on the Greek ones
what is your (getvar "SYSCODEPAGE") ?

iliekater

  • Mosquito
  • Posts: 9
Re: Retrieving Greek characters from Text objects
« Reply #4 on: November 02, 2021, 03:46:51 PM »
Hi . The above variable returns :
"ANSI_1253"

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Retrieving Greek characters from Text objects
« Reply #5 on: November 03, 2021, 05:21:55 AM »
do you get the same output when you run your code inside vlide and from autocad's command line?

iliekater

  • Mosquito
  • Posts: 9
Re: Retrieving Greek characters from Text objects
« Reply #6 on: November 03, 2021, 08:19:20 AM »
How can I run the code inside Vlide ? Is it possible ?

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine

mhupp

  • Bull Frog
  • Posts: 250