将参数传递给 .NET 定义的命令 [英] Passing arguments to .NET-defined commands

查看:27
本文介绍了将参数传递给 .NET 定义的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Autocad 2000i 的命令行上写一个命令,我想让 autocad 提示输入参数.然后我的 vb.net 程序将根据收到的参数进行操作.

I need to write a command on the command line on Autocad 2000i and I want autocad to prompt for a parameter. Then my vb.net program will act based on the recieved parameter.

基本上我想我的解决方案都在这里:http:///through-the-interface.typepad.com/through_the_interface/2006/09/passing_argumen.html

Basically I guess my solution is all here: http://through-the-interface.typepad.com/through_the_interface/2006/09/passing_argumen.html

问题是,我找不到对 Autodesk.AutoCAD.EditorInput 命名空间的引用.

Problem is, I cant find the reference to the Autodesk.AutoCAD.EditorInput namespace being used in there.

我在这里错过了什么?Autocad 2000i 中还没有 EditorInput 吗?

What am I missing here? Did EditorInput not exist in Autocad 2000i yet?

非常感谢您的回答.

我有一个 vb.net 项目,它为 autocad 添加了一个工具栏.我想让用户通过编写命令和参数来更改我工具栏中组合的选定值.

I have a vb.net project which adds a toolbar to autocad. I want to let the user change the selected value of a combo in my toolbar, by writing a commnad and a parameter.

我如何在我的项目中使用你的方法?我是否将 dvb 文件放在我的项目中?vba 文件可以集成到我的 vb.net 项目中吗?

How can I use your method in my project? Do I put the dvb file in my project? Can the vba file be integrated in my vb.net project?

非常感谢.

推荐答案

早在 2000 年,AutoCAD 就不存在 .Net API.事情是通过 LISP 或 VBA 或两者的组合完成的.这是要做的事情的简要说明.

.Net API did not exist for AutoCAD back in 2000. Things were done through LISP or VBA or a combination of both. Here is a brief explanation of things to do.

仅使用 VBA 的方法:

打开工具 > 宏 > Visual Basic 编辑器 (alt + F11)

Open Tools > Macro > Visual Basic Editor (alt + F11)

输入您的代码:

Sub Test()

Dim str As String
str = InputBox("Enter radius:")

MsgBox str

End Sub

在命令提示符下输入"-vbarun"(不带引号)

Type "-vbarun" in command prompt(without quotes)

输入"Thisdrawing.Test" (modulename.functionname)

Type "Thisdrawing.Test" (modulename.functionname)

VBA + Lisp 方式 -(我的首选方法)

如上所述在编辑器中输入您的代码.保存您的 vba 文件(.dvb 格式).假设它位于 D:Macros 文件夹中,名为 MyDvb.dvb.

Type your code in the editor as mentioned above. Save your vba file (.dvb format)..suppose it is in D:Macros folder with the name MyDvb.dvb.

创建一个新的 Lisp 文件(打开记事本并输入下面的代码并保存为 .lsp 扩展名)该 lisp 文件将用于调用所有 VBA 宏.

Create a new Lisp File(open a notepad and type the code below and save as .lsp extension) This lisp file will be used to call all the VBA macros.

(defun c:testcommand()
  (command "vbarun" "D:/Macros/MyDvb.DVB!ThisDrawing.Test")
)

现在通过在命令提示符下键入 "ap" 一次加载这个 lisp.这有助于我们保持会话可用的命令.

now load this lisp for one time by typing "ap" at the command prompt. This helps us to keep the commands available for the session.

输入"testcommand",你会看到你的代码被执行了

Type "testcommand" and you will see your code executed

这篇关于将参数传递给 .NET 定义的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆