明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: zhhunicorn

[基础] lisp如何调用外部命令?

  [复制链接]
发表于 2011-5-30 17:17:51 | 显示全部楼层
本帖最后由 caoyin 于 2011-5-30 17:38 编辑
zhhunicorn 发表于 2011-5-30 09:37
这个函数不错,不用安装其他东西了。
但是在启动了a.exe之后,没等a.exe计算的数据出来就往下执行了。 ...


可以在PGP文件里面定义外部命令,其中Bit flag设置为0,可以控制是否等待程序执行完毕

;  <Command name>,[<Shell request>],<Bit flag>, [ * ]<Prompt>,
;  The bits of the bit flag have the following meanings:
;  Bit 1: if set, don't wait for the application to finish
;  Bit 2: if set, run the application minimized
;  Bit 4: if set, run the application "hidden"
;  Bit 8: if set, put the argument string in quotes

;  Fill the "bit flag" field with the sum of the desired bits.
;  Bits 2 and 4 are mutually exclusive; if both are specified, only
;  the 2 bit is used. The most useful values are likely to be 0
;  (start the application and wait for it to finish)
, 1 (start the
;  application and don't wait), 3 (minimize and don't wait), and 5
;  (hide and don't wait). Values of 2 and 4 should normally be avoided,
;  as they make AutoCAD unavailable until the application has completed.
;
;  Bit 8 allows commands like DEL to work properly with filenames that
;  have spaces such as "long filename.dwg".  Note that this will interfere
;  with passing space delimited lists of file names to these same commands.
;  If you prefer multiplefile support to using long file names, turn off
;  the "8" bit in those commands.




发表于 2011-5-30 22:05:34 | 显示全部楼层
本帖最后由 yshf 于 2011-5-30 22:07 编辑

根据以前在晓东CAD家园上找到的改写:

  1. (setq *wsh (vlax-create-object "wscript.shell"))
  2. (vlax-invoke *wsh 'run "a.exe" 5 1)
  3. ......
  4. 你的程序
等a.exe运行了再运行你的程序。
 楼主| 发表于 2011-6-1 15:34:07 | 显示全部楼层
caoyin 发表于 2011-5-30 17:17
可以在PGP文件里面定义外部命令,其中Bit flag设置为0,可以控制是否等待程序执行完毕

;  ,[],, [ * ...

谢谢斑竹,比较倾向你这个方式。
把a.exe放在系统支持文件目录下
在pgp文件中做了如下修改:

;  Examples of external commands for command windows

DEL,       DEL,            8,要删除的文件: ,
DIR,       DIR,            8,指定文件: ,
SH,        ,               1,*操作系统命令: ,
SHELL,     ,               1,*操作系统命令: ,
START,     START,          1,*要启动的应用程序: ,
TYPE,      TYPE,           8,要列出的文件: ,
a,               a,            0,
在运行lsp程序:
(startapp "a" "")
(setq i 0)
结果还是没有等a.exe运行完毕。
究竟该怎么修改这个pgp文件呢

点评

这样调用就不能用startapp 了,而是command了  发表于 2011-6-1 18:11
 楼主| 发表于 2011-6-1 15:36:40 | 显示全部楼层
本帖最后由 zhhunicorn 于 2011-6-1 15:37 编辑
yshf 发表于 2011-5-30 22:05
根据以前在晓东CAD家园上找到的改写: 等a.exe运行了再运行你的程序。


这个果然轻松搞定。非常感谢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-10 10:08 , Processed in 0.152737 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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