|
可以使用一个套件来动态加载你的插件- using Autodesk.AutoCAD.Runtime;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace ArxDotNetCourse
- {
- public class DebugAdapter
- {
- private Action cmd1;
- public DebugAdapter()
- {
- Reload();
- }
- [CommandMethod("cmd1")]
- public void Cmd1()
- {
- cmd1?.Invoke();
- }
- [CommandMethod("reload1")]
- public void Reload()
- {
- FileInfo adapterFileinfo = new FileInfo(Assembly.GetExecutingAssembly().Location);
- string assemblyPath = Path.Combine(adapterFileinfo.DirectoryName, "FunctionalGraph.dll");
- Assembly targetAssembley = Assembly.Load(File.ReadAllBytes(assemblyPath));
- Type targetType = targetAssembley.GetType("FunctionalGraph.Class1");
- MethodInfo targetMethod = targetType.GetMethod("Cmd1");
- Object targetObject = Activator.CreateInstance(targetType);
- cmd1 = () => targetMethod.Invoke(targetObject, null);
- }
- }
- }
复制代码 |
|