明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2023|回复: 6

代码累赘求精简

[复制链接]
发表于 2011-12-6 12:25 | 显示全部楼层 |阅读模式
(setvar "cmdecho" 0)
  (if (findfile "转换.dvb")
    (progn
      (command "_vbaunload" "转换.dvb")
      (command "_vbaload" (findfile "转换.dvb"))
     
    )
  )
  (princ)
(setvar "cmdecho" 0)
  (if (findfile "tiqu.dvb")
    (progn
      (command "_vbaunload" "tiqu.dvb")
      (command "_vbaload" (findfile "tiqu.dvb"))
    )
  )
  (princ)
(setvar "cmdecho" 0)
  (if (findfile "图块管理1.dvb")
    (progn
      (command "_vbaunload" "图块管理1.dvb")
      (command "_vbaload" (findfile "图块管理1.dvb"))
     )
  )
  (princ)
(setvar "cmdecho" 0)
  (if (findfile "duqu.dvb")
    (progn
      (command "_vbaunload" "duqu.dvb")
      (command "_vbaload" (findfile "duqu.dvb"))
    )
  )
(princ)  
(setvar "cmdecho" 0)
  (if (findfile "查找替换.dvb")
    (progn
      (command "_vbaunload" "查找替换.dvb")
      (command "_vbaload" (findfile "查找替换.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "单位转换.dvb")
    (progn
      (command "_vbaunload" "单位转换.dvb")
      (command "_vbaload" (findfile "单位转换.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "调整文字间距.dvb")
    (progn
      (command "_vbaunload" "调整文字间距.dvb")
      (command "_vbaload" (findfile "调整文字间距.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "弧形文字.dvb")
    (progn
      (command "_vbaunload" "弧形文字.dvb")
      (command "_vbaload" (findfile "弧形文字.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "块编辑.dvb")
    (progn
      (command "_vbaunload" "块编辑.dvb")
      (command "_vbaload" (findfile "块编辑.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "图层切换.dvb")
    (progn
      (command "_vbaunload" "图层切换.dvb")
      (command "_vbaload" (findfile "图层切换.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "图层切换2.dvb")
    (progn
      (command "_vbaunload" "图层切换2.dvb")
      (command "_vbaload" (findfile "图层切换2.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "文字编辑器.dvb")
    (progn
      (command "_vbaunload" "文字编辑器.dvb")
      (command "_vbaload" (findfile "文字编辑器.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "文字遮罩.dvb")
    (progn
      (command "_vbaunload" "文字遮罩.dvb")
      (command "_vbaload" (findfile "文字遮罩.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "波纹管.dvb")
    (progn
      (command "_vbaunload" "波纹管.dvb")
      (command "_vbaload" (findfile "波纹管.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "music.dvb")
    (progn
      (command "_vbaunload" "music.dvb")
      (command "_vbaload" (findfile "music.dvb"))
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "AutoLayer.dvb")
    (progn
      (command "_vbaunload" "AutoLayer.dvb")
      (command "_vbaload" (findfile "AutoLayer.dvb"))
     (command "-vbarun" "ALC")
    )
  )
(princ)
(setvar "cmdecho" 0)
  (if (findfile "设置标注样式.dvb")
    (progn
      (command "_vbaunload" "设置标注样式.dvb")
      (command "_vbaload" (findfile "设置标注样式.dvb"))
     (command "_-vbarun" "AddDimStyle")
    )
  )
(princ)
(command   "_-VBARUN"  "Testcaidan_Dll")

点评

代码结构一样的,可以用一个表,用foreach对表中的每一个元素执行表达式  发表于 2011-12-6 17:20
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2011-12-6 19:40 | 显示全部楼层
本帖最后由 cabinsummer 于 2011-12-6 19:41 编辑

(foreach app '("转换" "tiqu" "图块管理1" "duqu" "查找替换" "单位转换" "调整文字间距" "弧形文字" "块编辑" "图层切换" "图层切换2" "文字编辑器" "文字编辑器" "文字遮罩" "波纹管" "music" "AutoLayer" "设置标注样式")
(setvar "cmdecho" 0)
  (setq app (strcat app ".dvb"))
  (if (findfile app)
    (progn
      (command "_vbaunload" app)
      (command "_vbaload" (findfile app))
    )
  )
  (princ)
)
 楼主| 发表于 2011-12-6 23:43 | 显示全部楼层
这个可以加载DVB,但是会显示几百个“未找到宏”的字样

怎么回事啊?

用回我以前的那个就不会显示“未找到宏”的字样
 楼主| 发表于 2011-12-7 00:15 | 显示全部楼层
我将执行VBA的语句换了一个地方搞定了,谢谢各位大哥!!
但是十字光标闪动好厉害哦,怎么解决啊?
发表于 2011-12-7 07:57 | 显示全部楼层
dcl1214 发表于 2011-12-6 23:43
这个可以加载DVB,但是会显示几百个“未找到宏”的字样

怎么回事啊?

你的最后三个函数里面有VBARUN,我给的里面没有
 楼主| 发表于 2011-12-7 08:08 | 显示全部楼层
加载DVB的方案已经解决,但是十字光标闪动厉害的问题没有解决
发表于 2024-6-1 01:17 来自手机 | 显示全部楼层
用一堆的command
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-6-26 18:26 , Processed in 0.155714 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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