| | |
| | | using Autodesk.Revit.Attributes; |
| | | using Autodesk.Revit.UI; |
| | | using HStation.RevitDev.RevitDataExport.Forms; |
| | | using Spire.AI.Api; |
| | | using System; |
| | | using System.IO; |
| | | using System.Reflection; |
| | |
| | | [Transaction(TransactionMode.Manual)] |
| | | public class Application : IExternalApplication |
| | | { |
| | | UIControlledApplication m_uiControlledApp; |
| | | private readonly string m_familyPanelName = "族列表"; |
| | | public Result OnShutdown(UIControlledApplication application) |
| | | { |
| | |
| | | |
| | | public Result OnStartup(UIControlledApplication application) |
| | | { |
| | | m_uiControlledApp = application; |
| | | |
| | | //创建菜单 管道系统分析 |
| | | CreateRibbon_PipeSystemAnalysis(application); |
| | | |
| | | //创建菜单 泵系统分析 |
| | | CreateRibbon_PumpSystemAnalysis(application); |
| | | |
| | | //注册停靠面板 |
| | | RegistDockablePanel(application); |
| | | |
| | | return Result.Succeeded; |
| | | } |
| | |
| | | PushButtonData pdata = new PushButtonData("命令按钮", "系统详情", path, className); |
| | | PushButton pBtn = panel.AddItem(pdata) as PushButton; |
| | | |
| | | string imagePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/Data/Image/analysis.png"; |
| | | string imagePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "../../../../Data/Image/analysis.png"; |
| | | pBtn.LargeImage = new BitmapImage(new Uri(imagePath));//32 * 32 |
| | | pBtn.ToolTip = "Revit插件简介"; |
| | | |
| | | //注册停靠面板 |
| | | RegistDockablePanel(application); |
| | | application.ControlledApplication.DocumentOpened += ControlledApplication_DocumentOpened; |
| | | application.ControlledApplication.DocumentCreated += ControlledApplication_DocumentCreated; |
| | | } |
| | | |
| | | private void ControlledApplication_DocumentCreated(object sender, Autodesk.Revit.DB.Events.DocumentCreatedEventArgs e) |
| | | { |
| | | HideDockablePane(); |
| | | } |
| | | |
| | | private void ControlledApplication_DocumentOpened(object sender, Autodesk.Revit.DB.Events.DocumentOpenedEventArgs e) |
| | | { |
| | | HideDockablePane(); |
| | | } |
| | | |
| | | private void HideDockablePane() |
| | | { |
| | | Guid guid = new Guid(Common.GlobalResource.Guid_FamilyPanel); |
| | | DockablePaneId id = new DockablePaneId(guid); |
| | | DockablePane pane = null; |
| | | try |
| | | { |
| | | pane = m_uiControlledApp.GetDockablePane(id); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | string message = ex.Message; |
| | | } |
| | | pane.Hide(); |
| | | } |
| | | |
| | | private void CreateRibbon_PipeSystemAnalysis(UIControlledApplication application) |
| | |
| | | //程序集路径--最好写成相对位置 |
| | | string Path1 = Assembly.GetExecutingAssembly().Location; |
| | | //程序集的名称、所使用的类名——"主程序集命名空间.主程序类名" |
| | | string Class1 = "RevitDataExport.Export"; |
| | | string Class1 = "HStation.RevitDev.RevitDataExport.Export"; |
| | | //3.2定义PushButtonData命令按钮数据资料,绑定程序集 |
| | | PushButtonData pdata = new PushButtonData("命令按钮", "系统详情", Path1, Class1); |
| | | //3.3将PushButton添加到面板中 |
| | | PushButton push = panel1.AddItem(pdata) as PushButton; |
| | | //3.4为PushButton添加图标 |
| | | //可把图片资源加载入项目中,方便把图片的路径写成相对路径,并进行修改属性(图片的生成操作,改位:嵌入的资源) |
| | | Stream imgPath = Assembly.GetExecutingAssembly().GetManifestResourceStream("RevitDataExport.Resources.piping_system_detect2.png"); |
| | | push.LargeImage = BitmapFrame.Create(imgPath); |
| | | string imagePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "../../../../Data/Image/analysis.png"; |
| | | push.LargeImage = new BitmapImage(new Uri(imagePath));//32 * 32 |
| | | //3.5设置命令按钮的默认提示信息 |
| | | push.ToolTip = "Revit插件简介"; |
| | | } |