明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2139|回复: 3

[密技]:如何不使用sendcommand在vba中对lisp求值

[复制链接]
发表于 2002-9-26 10:25:00 | 显示全部楼层 |阅读模式
寄件者:Mark Holder (holderm@atscorporation.com) 主旨:Re: Calling Autolisp Programs From VB - Map 2000 新闻群组:autodesk.AutoCAD.customization.vba View this article only 日期:1999/06/10  
Tony,

Thanks once again for the info. For others who may be interested, I went looking and found the
following link:

http://www.autodesk.com/products/ac...iles/avlisp.exe

The following is an excerpt:

<<snip>>
Visual LISP as an ActiveX Server

Visual LISP can function as an ActiveX server.  This is useful when using VBA dialogs to control
Visual LISP applications.  For instance, a programmer can create dialogs using the VBA visual
tools for layout. They can then have the actions invoke Visual LISP.

Any Visual LISP function may be invoked and any symbol may have its value referenced or set.
Parameters and results are all variants.  In the following example

Sub Hello()
    Set vla = CreateObject("VL.Application.1")
    Set vld = vla.ActiveDocument
    Set vl_read = vld.Functions.Item("read")
    Set vl_eval = vld.Functions.Item("eval")
    Set vl_hello = vl_read.funcall("(defun hello (x)(print x))")
    Set vl_hello = vl_eval.funcall(vl_hello)
    Set vl_hello = vld.Functions.Item("hello")
    ret = vl_hello.funcall("world")
    MsgBox ret, vbOKOnly
End Sub

we obtain access to Visual LISPs read and eval functions.  We then use those to define a hello
function, which we then call, displaying its return value in a message box.
<<snip>>

Of interest in it is the phrase "arameters and results are all variants". We may get better
results by declaring our variables as variants (which can contain an object) rather than declaring
them directly as objects.

I'm more optimistic about calling VLisp from VB after seeing Autodesk endorse the idea.

Tony Tanzillo wrote:
<<snip>>The Visual LISP white paper on Autodesk's web page has an example in VBA that should work.
<<snip>>
 楼主| 发表于 2002-9-26 10:37:00 | 显示全部楼层

这里不支持html显示,很不方便。详见

http://www.xdcad.com/forum/showthread.php?s=a4cbf78469d92225e0118bb95af26aa9&postid=71141#post71141
发表于 2002-9-26 21:26:00 | 显示全部楼层

显示嵌套网页问题争取这段时间写出来

发表于 2010-7-1 11:07:00 | 显示全部楼层
优点
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 00:31 , Processed in 0.165121 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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