Author Topic: Going Global  (Read 1310 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Going Global
« on: November 13, 2006, 05:00:29 AM »
Hi all,

I thought it might be cool to show that one can support the Asian languages in Autolisp applications now with ac2007. Just use Unicode Hex. It sure would be nice if the vlide supported Unicode. You can paste (princ "请 指 定 间 距") at the command line but not in vlide. PS don’t be mad if I butchered a particular language 


Code: [Select]
;;;-==-==-==-==-==-==-=-==-==-=-=-==-=-=-==-==-==-==-==-==-==-==-==-==
;;; Language Mapper for Autocad 2007+
;;;-==-==-==-==-==-==-=-==-==-=-=-==-=-=-==-==-==-==-==-==-==-==-==-==
(defun lpromt (a / flag lang)
 (setq lang (strcase (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-product-key)) "Language")))
 (cond
  ((eq lang "CHINESE")
   (setq flag (CHINESEPrompt a))
  )
  ((eq lang "FRANÇAIS")
   (setq flag (FRANÇAISPrompt a))
  )
  ((eq lang "DEUTSCH")
   (setq flag (DEUTSCHPrompt a))
  )
  ((eq lang "ESPANOL")
   (setq flag (ESPANOLPrompt a))
  )
  (T                                ; for unknown languages set to ...
    (setq flag (CHINESEPrompt a))
   ;(setq flag (FRANÇAISPrompt a))
   ;(setq flag (DEUTSCHPrompt a))
   ;(setq flag (ESPANOLPrompt a))
   ;(setq flag (ENGLISHPrompt a))
  )
 )
 (if (= flag nil)
  (setq flag (ENGLISHPrompt a))
 )
 flag
)
;;;
(defun CHINESEPrompt (x)
 (cdr (assoc x '(              ; Using unicode Hex
        (1 . "\U+9009 \U+62E9 \U+5BF9 \U+8C61 :") ; Select Object
        (2 . "\U+8BF7 \U+6307 \U+5B9A \U+95F4 \U+8DDD") ; Specify offset distance
     )))
)
;;;
(defun FRANÇAISPrompt (x)
 (cdr (assoc x '((1 . "Choisissez L'Objet :"); Select Object
                 (2 . "Indiquez la distance excentrée")))); Specify offset distance
)
;;;
(defun DEUTSCHPrompt (x)
 (cdr (assoc x '((1 . "Wählen Sie Gegenstand Vor :") ; Select Object
                 (2 . "Spezifizieren Sie Offsetabstand")))); Specify offset distance
)
(defun ESPANOLPrompt (x)
 (cdr (assoc x '((1 . "Seleccione El Objeto :") ; Select Object
                 (2 . "Especifique la distancia compensada")))); Specify offset distance
)
;;;
(defun ENGLISHPrompt (x)
 (cdr (assoc x '((1 . "Select Object :") ; Select Object
                 (2 . "Specify offset distance")))); Specify offset distance
)
;;;-==-==-==-==-==-==-=-==-==-=-=-==-=-=-==-==-==-==-==-==-==-==-==-==
;;; Example application
(defun C:Dof (/ offdist offsetdist pickent pickobj)
 (vl-load-com)
 (setvar "ErrNo" 0)
 (setq OFFSETDIST (getvar "OFFSETDIST")
       offDist (getreal (strcat "\n" (lpromt 2) " <" (rtos OFFSETDIST) ">: "))
 )
 (if (= offDist nil)
  (setq offDist OFFSETDIST)
 )
 (while (and
(not (setq pickEnt (entsel (strcat "\n" (lpromt 1)))))
(/= 52 (getvar "ErrNo"))
)
 )
 (cond
  ((and
    pickEnt
    (setq pickObj (vlax-EName->vla-Object (car pickEnt)))
   )
   (vla-Offset pickObj (/ offDist 2))
   (vla-Offset pickObj (/ (- offDist) 2))
   (vla-delete pickObj)
  )
 )
 (setvar "OFFSETDIST" offDist)
 (princ)
)


P.s. Way too much goofing off. I just wrote a (string->MorseCode) (MorseCode->string)