CAD二开之打开时插件命令自动加载(RibbonUI自动显示)

一、背景

小伙伴们在基于.net做CAD开发时,使用.bundle打包文件时,如果需要打开CAD时,插件的某个命令,比如下面的FirstDo在CAD启动后,就能执行(例如初始化RibbonUI的显示)。

 [CommandMethod("FirstDo")]
 public void FirstDoAdd()
  {
      //....
  }

二、解决思路

对.bundle中的PackageContents.xml 文件进行配置即可
在里面加入这行代码:

  <Command Local="FirstDo" Global="AddRibbon" StartupCommand="FirstDo"/>
<?xml version="1.0" encoding="utf-8" ?>
<ApplicationPackage SchemaVersion="1.0" AppVersion="1.0"
    ProductCode="{02933C01-125D-48EF-B576-08C3AEF6A23K}"
    Name="xxx插件"
>
  <CompanyDetails
    Name="xxx有限公司"
    Email="[email protected]"
  />
  <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*"/>
  <Components>
    <ComponentEntry ModuleName="./Contents/xxx.dll" >
	  <Commands>
        <Command Local="FirstDo" Global="AddRibbon" StartupCommand="FirstDo"/>
      </Commands>
	</ComponentEntry>
  </Components>
</ApplicationPackage>

三、注意事项

1.我是黑夜の骑士,欢迎大家关注我的博客,笔者将持续输出BIM相关软件开发以及编程干货;
2.欢迎加入BIM行业开发交流1群,获取更多开发资料 群号:711844216

发布了115 篇原创文章 · 获赞 115 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/birdfly2015/article/details/104005600