马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
先留存
- [LispFunction("InvokeMethod")]
- public Object MyGetMethod(ResultBuffer rb)
- {
- if (rb != null)
- {
- TypedValue[] values = rb.AsArray();
- if (values [0].TypeCode == (int)LispDataType .ObjectId && values .Length >= 2)
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- Transaction tr = db.TransactionManager.StartTransaction();
- var id = (ObjectId) values[0].Value;
- using (tr)
- {
- try
- {
- var argValues = new object[values .Length - 2];
- if (values.Length > 2)
- {
- for (int i = 0; i < argValues .Length; i++)
- {
- argValues[i] = values[i + 2].Value;
- }
- }
- var obj = (DBObject) id.GetObject(OpenMode.ForRead);
- var str = (string) values[1].Value;
- MethodInfo methodInfo = obj.GetType().GetMethod(str);
- if (methodInfo != null)
- {
- obj.UpgradeOpen();
- var result = methodInfo.Invoke(obj,
- BindingFlags .SuppressChangeType |BindingFlags .InvokeMethod |BindingFlags .IgnoreCase,
- null,argValues ,null);
- return result;
- }
- else
- {
- return null;
- }
- }
- catch (Autodesk.AutoCAD.Runtime.Exception)
- {
- return null;
- }
- }
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
- }
|