明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: print1985

[资源] 输入法自动切换V2.5--2021.9.3更新2013-2022版

    [复制链接]
发表于 6 天前 | 显示全部楼层
本帖最后由 zhangrunze 于 2025-3-8 08:32 编辑

网上找了一段,统计文本中英文数量切换;

  1. (vl-load-com)

  2. ; 修改为你的AganInp.dll路径(注意路径为双斜杠)
  3. (vl-cmdf "netload" "D:\\Support\\AganInp.dll")

  4. ; 快捷键定义
  5. (defun c:pz() (vl-cmdf "agpz")(princ)) ; 打开设置
  6. (defun c:gbs() (vl-cmdf "GC:UnloadInp")(princ)) ; 手动关闭输入法自动切换
  7. (defun c:dks() (vl-cmdf "GC:loadInp")(princ)) ; 手动打开输入法自动切换

  8. ; 文字内容
  9. (defun text-char-count (text / en-count zh-count char)
  10.   (setq en-count 0 zh-count 0)
  11.   (foreach char (explode text)
  12.     (if (wcmatch char "[a-zA-Z]")
  13.       (setq en-count (+ en-count 1))
  14.       (if (wcmatch char "[\\一-\\龥]")
  15.         (setq zh-count (+ zh-count 1))
  16.       )
  17.     )
  18.   )
  19.   (list en-count zh-count)
  20. )

  21. ; 鼠标双击事件处理器
  22. (defun double_click (a b / en end entype text en-count zh-count)
  23.   (if (setq en (nentselp (trans (car b) 0 1)))
  24.     (progn
  25.       (setq end (entget (car en)))
  26.       (setq entype (cdr (assoc 0 end)))
  27.       (if (wcmatch entype "*TEXT")
  28.         (progn
  29.           (setq text (cdr (assoc 1 end)))
  30.           (if (= entype "MTEXT")
  31.             (setq text (DK:mtext2text text))
  32.           )
  33.           ; 统计中英文字符
  34.           (setq (values en-count zh-count) (text-char-count text))
  35.           (if (> en-count zh-count)
  36.             (GC:cmdend "EN") ; 切换为英文
  37.             (GC:cmdstart "中文") ; 切换为中文
  38.           )
  39.         )
  40.       )
  41.     )
  42.   )
  43.   (princ)
  44. )

没有成功......

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-3-13 02:11 , Processed in 0.166796 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表