Solidworks二次开发平台 --- RyS.SwWorks [2015-09-18更新]
RyS.SwWorks 是一款基于.NET的Solidworks二次开发平台,该平台封装了插件注册、菜单、工具栏、侧边栏、Document接口,使得Solidworks开发和部署简单高效。
安装程序中自带开发示例程序。 并且提供一套模拟调试工具,使得Solidworks二次开发和调试更简单方便。
代码示例:
//添加菜单
SwWorksApp.MenuMgr.AddMenuItem(new swDocumentTypes_e[] { swDocumentTypes_e.swDocNONE, swDocumentTypes_e.swDocPART, swDocumentTypes_e.swDocASSEMBLY, swDocumentTypes_e.swDocDRAWING },
"CreateCube@MyUserAddin1", "Create Cube", "\\sources\\images\\icons\\mark.bmp", OnCreateCube, OnCreateCubeEnable);
SwWorksApp.MenuMgr.AddMenuSeparator(new swDocumentTypes_e[] { swDocumentTypes_e.swDocNONE, swDocumentTypes_e.swDocPART, swDocumentTypes_e.swDocASSEMBLY, swDocumentTypes_e.swDocDRAWING },
"@MyUserAddin1");//分隔符
SwWorksApp.MenuMgr.AddMenuItem(new swDocumentTypes_e[] { swDocumentTypes_e.swDocNONE, swDocumentTypes_e.swDocPART, swDocumentTypes_e.swDocASSEMBLY, swDocumentTypes_e.swDocDRAWING },
"About@MyUserAddin1", "MyUserAddin1 About", "\\sources\\images\\icons\\about.bmp", OnAbout, null);

//添加工具栏
ISwToolBar toolbar = SwWorksApp.AddToolBar("MyUserAddin1", "MyUserAddin1 Tip", "MyUserAddin1 Hint");
if (toolbar != null)
{
ISwToolBarGroup group1 = toolbar.AddToolBarGroup("group1", new swDocumentTypes_e[] { swDocumentTypes_e.swDocNONE, swDocumentTypes_e.swDocPART, swDocumentTypes_e.swDocASSEMBLY, swDocumentTypes_e.swDocDRAWING });
group1.AddBarItem("CreateCube", "Create Cube", "Create Cube", "\\sources\\images\\icons\\mark.bmp", OnCreateCube, OnCreateCubeEnable);
group1.AddBarItem("About", "About", "About", "\\sources\\images\\icons\\about.bmp", OnAbout, null);
toolbar.EndUpdate();
}

//添加侧边栏
_myUC = new MyUserControl1(this);
SwWorksApp.AddTaskPaneView("MyUserAddin1", "\\sources\\images\\icons\\field_public.png", _myUC);

注册插件的方法有2种:注册表和手工加载
//注册表:可以通过手工运行插件相应的.reg文件或者程序自动写入注册信息
[HKEY_CLASSES_ROOT\Software\RySoft\Rys.SwWorks\Addins\MyUserAddin1]

//手工加载:在SwWorks的插件管理器中手工选择要加载的插件文件
具体详细请查看安装程序中示例项目MyUserAddin1(\samples\MyUserAddin1\)