1 Star 0 Fork 21

wangafeiBlogs / CADTools

forked from liuqihong / CADTools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CADTools

介绍

AutoCad 扩展工具平台

软件架构

最终程序的组织结构:

  • 插件目录
    • main.dll ----cad需要加载的主dll
    • support ----内裤目录
      • xxx.dll ----内裤的dll文件
    • plugins ----插件的目录
      • plugin1.dll ----用户自己编写的插件,由main.dll的程序进行加载到cad
      • plugin2.dll ----同上
      • ...

安装教程

  1. 下载 CadTools.dll,NFox.Cad.dll,NFox.Basal.dll三个dll到一个目录
  2. 在第一步的目录里建立 Plugins 目录
  3. 在cad里运行netload命令加载CadTools.dll
  4. 将您编写的插件dll放在第二步建立的Plugins目录里
  5. 重启cad之后会默认加载所有的插件

插件编写说明

  1. 新建一个类库项目
  2. 添加下列引用:
accoremgd.dll
acdbmgd.dll
acmgd.dll
adwindows.dll
cadtools.dll
nfox.basal.dll
nfox.cad.dll
presentationcore,
presentationframework
system.componentmodel.composition
  1. 添加using:
using System.ComponentModel.Composition;
using Autodesk.Windows;
using CADTools;
using Autodesk.AutoCAD.Runtime;
  1. 在类上添加特性:[Export(typeof(IPlugin))]
  2. 类继承PluginBase抽象类
  3. 实现MenuTab属性,具体语法见menutab语法说明
  4. 常规cad插件编写

MenuTab语法说明

MenuTab 其实就是一个RibbonTab的对象,可以按照常规的写法,一步步的生成这个对象,为了简化操作特自定义了一系列的函数来简化构造RibbonTab对象。

  1. 定义一个Ribbon选项卡对象

语法: new Tab("xxx"){}

  1. 在选项卡对象大括号内添加Ribbon面板对象

语法:new Panel("测试"){},需要多少个面板就添加多少个

现在代码类似这个样子:

new Tab("插件平台")
{
    new Panel("测试1"){},
    new Panel("测试2"){},
    new Panel("测试3"){},
    ...
}
  1. 在面板对象大括号内添加按钮
  • 普通按钮语法:

    {name, cmd, [image], [toolTip], [size], [orient]}

    解释:

    {功能名称、功能命令、功能图标[默认缺省]、鼠标悬停提示[默认缺省]、图标大小[默认缺省]、文字和图标的位置[默认缺省]}

    • namestring类型
    • cmdstring类型
    • imageBitmap类型
    • toolTipRibbonToolTip类型
    • sizeRibbonItemSize类型
    • orientOrientation枚举类型
  • 换行语法:

    {BreakType.xxx}

    解释:

    BreakType为一个枚举类型,分别为:

    • BreakType.Row 按钮换行
    • BreakType.Panel 面板换行,面板换行的效果就是面板下拉显示的那个区域
  • 分隔符语法:

    {RibbonSeparatorStyle.xxx}

    解释:

    RibbonSeparatorStyle为一个枚举类型,分别为:

    • RibbonSeparatorStyle.Line 直线
    • RibbonSeparatorStyle.Spacer 空白
    • RibbonSeparatorStyle.Invisible 我也不知道是啥
  1. 面板内除了添加上述三种按钮之外,还可以添加下拉按钮和行面板
  • 下拉按钮语法

    new SplitButton("heihei"){}

    特殊性提示:

    • 下拉按钮,只能添加普通按钮
    • 下拉按钮会自动排列,不需要换行
  • 行面板语法

    new RowPanel("hoho"){}

    特殊性提示:

    • 行面板的使用方法和面板几乎一样,除了不能添加面板换行
    • 行面板的用途只要是区分一个面板的内的不同区域
    • 最佳用途为 N × N 个按钮的排列
  1. 现在代码类似这个样子:
new Tab("插件平台")
{
    new Panel("测试1")
    {
        {name, cmd, image, toolTip, size, orient},
        {name, cmd, image, toolTip, size, orient},
        {RibbonSeparatorStyle.Line},
        {name, cmd, image, toolTip, size, orient},
        {name, cmd, image, toolTip, size, orient},
        new SplitButton("heihei")
        {
            {name, cmd, image, toolTip, size, orient},
            {name, cmd, image, toolTip, size, orient},
            ...
        },
        new RowPanel("hoho")
        {
            {name, cmd, image, toolTip, size, orient},
            {BreakType.Row}
            {name, cmd, image, toolTip, size, orient},
            {BreakType.Row}
            {RibbonSeparatorStyle.Space},
            {name, cmd, image, toolTip, size, orient},
            {BreakType.Row}
            {name, cmd, image, toolTip, size, orient},
            ...
        },
        ...
    },
    new Panel("测试2")
    {
        
    },
    new Panel("测试3")
    {
        
    },
    ...
}

在下拉按钮中只可添加普通按钮,在行面板中可以添加普通按钮/换行/分隔符/下拉按钮

放心,上述代码在vs里都有自动提示的。

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

码云特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. 码云官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解码云上的优秀开源项目
  4. GVP 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
  5. 码云官方提供的使用手册 https://gitee.com/help
  6. 码云封面人物是一档用来展示码云会员风采的栏目 https://gitee.com/gitee-stars/
MIT License Copyright (c) 2019 vicwjb Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

AutoCad 扩展工具平台 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/wangafeiblogs/CADTools.git
git@gitee.com:wangafeiblogs/CADTools.git
wangafeiblogs
CADTools
CADTools
master

搜索帮助