- 积分
- 13757
- 明经币
- 个
- 注册时间
- 2007-1-15
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 print1985 于 2021-2-1 23:38 编辑
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.Runtime;
- namespace ClassLibrary1
- {
- public class Class1
- {
- [CommandMethod("Test1", CommandFlags.Session)]
- static public void Test1()
- {
- ResultBuffer pa = new ResultBuffer(); //lisp参数
- ResultBuffer rb = new ResultBuffer(); //lisp返回值
- pa.Add(new TypedValue((int)LispDataType.Text, "c:lisp1")); //lisp函数名字
- pa.Add(new TypedValue((int)LispDataType.Double, 123)); //lisp参数1 Double类型也可直接用5001代码
- //pa.Add(new TypedValue(5001, 123)); //也可直接用5001代码
- rb = Application.Invoke(pa); //调用lisp函数,并取得返回值
- if (rb != null)
- {
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- TypedValue[] Array = rb.AsArray(); //返回值为数组
- string str = Array[0].Value.ToString();
- ed.WriteMessage("lisp返回值为:" + str);
- }
- //lisp参数类型及代码
- //None = 5000,
- //Double = 5001,
- //Point2d = 5002,
- //Int16 = 5003,
- //Angle = 5004,
- //Text = 5005,
- //ObjectId = 5006,
- //SelectionSet = 5007,
- //Orientation = 5008,
- //Point3d = 5009,
- //Int32 = 5010,
- //Void = 5014,
- //ListBegin = 5016,
- //ListEnd = 5017,
- //DottedPair = 5018,
- //Nil = 5019,
- //T_atom = 5021
- }
- }
- }
lisp源码:(defun c:lisp1(a) (princ (strcat "C#传入lisp参数为:" (rtos a) "\n")) 456)
关于C#调用lisp的源码好像较少,我弄了个超简单的,给需要的朋友
|
|