HStation.RevitDev/RevitDataExport/Common/Global.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HStation.RevitDev/RevitDataExport/Entity/CategoryConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HStation.RevitDev/RevitDataExport/HStation.RevitDev.RevitDataExport.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HStation.RevitDev/RevitDataExport/Plugin/Application.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HStation.RevitDev/RevitDataExport/Plugin/Command.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
HStation.RevitDev/RevitDataExport/Common/Global.cs
@@ -1,19 +1,69 @@ using System; using HStation.RevitDev.RevitDataExport.Enum; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Reflection; namespace HStation.RevitDev.RevitDataExport.Common { public static class GlobalResource { public static List<string> DockablePanelIds => new List<string> { "8AF8DA72-120F-44A0-81DD-5DD24EDAB919", "1A2728E3-51FF-4084-B0B6-F6DAD26A56FB" public static Dictionary<YWFamilyType, string> DockablePanelDict => new Dictionary<YWFamilyType, string> { {YWFamilyType.YWFT_Pump, "8AF8DA72-120F-44A0-81DD-5DD24EDAB919"}, {YWFamilyType.YWFT_Valve, "1A2728E3-51FF-4084-B0B6-F6DAD26A56FB"}, {YWFamilyType.YWFT_Pipe, "CB879681-B8E8-4FE2-BF57-4C86068D2C89"}, {YWFamilyType.YWFT_Four_Joint, "AAB55EEE-8450-4848-9C89-0322BBE94F5A"}, {YWFamilyType.YWFT_Elbow, "C357EC81-09FF-41C5-8E32-FE71E30EA394"}, {YWFamilyType.YWFT_Blocker, "0250FA8F-56C3-4355-817D-60B515CAD90E"}, {YWFamilyType.YWFT_Fire_Hydrant, "34E2EAD1-3D49-46C9-9942-451DD0192229"}, {YWFamilyType.YWFT_Heat_Exchanger, "056EAACD-ED75-4854-8F3C-A4A43007BF31"}, {YWFamilyType.YWFT_Shower, "D4AA8261-406E-44FF-A1EE-531153FA9709"}, {YWFamilyType.YWFT_Three_Joint, "1BAA114A-E355-402C-B91D-569882D12987"}, {YWFamilyType.YWFT_Water_Box, "44951F67-0C2F-4B02-B988-8B5F06295A18"}, {YWFamilyType.YWFT_Water_Meter, "28354DCD-C11F-4EE8-89F8-72B9A93FD9E6"}, {YWFamilyType.YWFT_Water_Pool, "2DFB190E-1FD9-4CC6-8F85-AD3B19745ACF"}, }; public static int ThumbnailSize => 150; public static string CurrentRevitVersion = string.Empty; public static string BinDirectory { get { string result = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); return result; } } public static string DataDirectory { get { string result = Path.Combine(Path.GetDirectoryName(BinDirectory), "Data"); return result; } } public static string FamilysDirectory { get { string result = Path.Combine(DataDirectory, "Familys"); return result; } } public static string ImageDirectory { get { string result = Path.Combine(DataDirectory, "Image"); return result; } } } } HStation.RevitDev/RevitDataExport/Entity/CategoryConfig.cs
@@ -1,10 +1,4 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HStation.RevitDev.RevitDataExport.Entity namespace HStation.RevitDev.RevitDataExport.Entity { public class CategoryConfig { HStation.RevitDev/RevitDataExport/HStation.RevitDev.RevitDataExport.csproj
@@ -66,11 +66,15 @@ </Reference> <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> <Reference Include="RevitAPI"> <HintPath>..\..\..\Program Files\Autodesk\Revit 2022\RevitAPI.dll</HintPath> <Reference Include="RevitAPI, Version=22.0.0.0, Culture=neutral, processorArchitecture=AMD64"> <SpecificVersion>False</SpecificVersion> <HintPath>Reference\RevitAPI.dll</HintPath> <Private>False</Private> </Reference> <Reference Include="RevitAPIUI"> <HintPath>..\..\..\Program Files\Autodesk\Revit 2022\RevitAPIUI.dll</HintPath> <Reference Include="RevitAPIUI, Version=22.0.0.0, Culture=neutral, processorArchitecture=AMD64"> <SpecificVersion>False</SpecificVersion> <HintPath>Reference\RevitAPIUI.dll</HintPath> <Private>False</Private> </Reference> <Reference Include="Spire.XLS, Version=13.10.1.0, Culture=neutral, PublicKeyToken=663f351905198cb3, processorArchitecture=MSIL"> <HintPath>..\packages\Spire.XLS.13.10.1\lib\net40\Spire.XLS.dll</HintPath> @@ -99,25 +103,24 @@ <Reference Include="WindowsBase" /> </ItemGroup> <ItemGroup> <Compile Include="Common\DescriptionExtension.cs" /> <Compile Include="Common\Global.cs" /> <Compile Include="Common\Log.cs" /> <Compile Include="Common\MEPHelper.cs" /> <Compile Include="Common\NetWorkHelper.cs" /> <Compile Include="Common\ThumbnailUtils.cs" /> <Compile Include="Entity\ExternalCommand_CreateInstance.cs" /> <Compile Include="Entity\ExternalEvent_CreateInstance.cs" /> <Compile Include="Entity\FamilyLoadOptions.cs" /> <Compile Include="Entity\UnitType.cs" /> <Compile Include="Enum\FamilyType.cs" /> <Compile Include="Forms\Form_CheckResult.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Forms\Form_CheckResult.Designer.cs"> <DependentUpon>Form_CheckResult.cs</DependentUpon> </Compile> <Compile Include="Forms\Wpf_FamilyPanel_Wall.xaml.cs"> <DependentUpon>Wpf_FamilyPanel_Wall.xaml</DependentUpon> </Compile> <Compile Include="Forms\Wpf_FamilyPanel_Foundation.xaml.cs"> <DependentUpon>Wpf_FamilyPanel_Foundation.xaml</DependentUpon> <Compile Include="Forms\Wpf_FamilyPanel.xaml.cs"> <DependentUpon>Wpf_FamilyPanel.xaml</DependentUpon> </Compile> <Compile Include="Parser\Qita.cs" /> <Compile Include="Plugin\Application.cs" /> @@ -125,6 +128,7 @@ <Compile Include="Utility\DialogHelper.cs" /> <Compile Include="Utility\DockPaneUtil.cs" /> <Compile Include="Utility\ExcelHelper.cs" /> <Compile Include="Utility\ExternalCommandUtils.cs" /> <Compile Include="Utility\ParameterOperator.cs" /> <Compile Include="Entity\CategoryConfig.cs" /> <Compile Include="Forms\Form_SystemSelect.cs"> @@ -161,10 +165,13 @@ <Compile Include="Common\WaterRemark.cs" /> <Compile Include="Utility\ParserManager.cs" /> <Compile Include="Utility\PropertyUitlity.cs" /> <Compile Include="Service\SearchService.cs" /> <Compile Include="Utility\RevitUtil.cs" /> <Compile Include="Utility\Ribbon.cs" /> <Compile Include="Utility\VersionUtil.cs" /> <Compile Include="Utility\ViewHelper.cs" /> </ItemGroup> <ItemGroup> <Folder Include="Enum\" /> <Folder Include="Interface\" /> </ItemGroup> <ItemGroup> @@ -185,11 +192,7 @@ <EmbeddedResource Include="Resources\piping_system_detect2.png" /> </ItemGroup> <ItemGroup> <Page Include="Forms\Wpf_FamilyPanel_Wall.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> <Page Include="Forms\Wpf_FamilyPanel_Foundation.xaml"> <Page Include="Forms\Wpf_FamilyPanel.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> HStation.RevitDev/RevitDataExport/Plugin/Application.cs
@@ -1,12 +1,10 @@ using Autodesk.Revit.Attributes; using Autodesk.Revit.UI; using HStation.RevitDev.RevitDataExport.Forms; using Spire.AI.Api; using HStation.RevitDev.RevitDataExport.Common; using HStation.RevitDev.RevitDataExport.Utility; using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Windows.Documents; using System.Windows.Media.Imaging; namespace HStation.RevitDev.RevitDataExport.Plugin @@ -14,9 +12,8 @@ [Transaction(TransactionMode.Manual)] public class Application : IExternalApplication { UIControlledApplication m_uiControlledApp; private readonly string m_panelFoundationName = "基础族列表"; private readonly string m_panelWallName = "挡墙族列表"; UIControlledApplication m_application; public Result OnShutdown(UIControlledApplication application) { return Result.Succeeded; @@ -24,94 +21,88 @@ public Result OnStartup(UIControlledApplication application) { m_uiControlledApp = application; m_application = application; Ribbon ribbon = new Ribbon(application); RibbonPanel ribbonPanel = ribbon.CreateRibbon(); ribbonPanel.AddSeparator(); GlobalResource.CurrentRevitVersion = application.ControlledApplication.VersionNumber; //创建菜单 管道系统分析 CreateRibbon_PipeSystemAnalysis(application); //创建button CreateBottons(ribbon, ribbonPanel); //创建菜单 泵系统分析 CreateRibbon_PumpSystemAnalysis(application); ribbonPanel.AddSeparator(); RegistEvent(); return Result.Succeeded; } private void CreateRibbon_PumpSystemAnalysis(UIControlledApplication application) private static void CreateBottons(Ribbon ribbon, RibbonPanel ribbonPanel) { application.CreateRibbonTab("泵系统分析"); RibbonPanel panel = application.CreateRibbonPanel("泵系统分析", "泵系统分析"); string className1 = "HStation.RevitDev.RevitDataExport.PumpSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Pump, className1); string path = Assembly.GetExecutingAssembly().Location; string className = "HStation.RevitDev.RevitDataExport.PumpSystemAnalysis"; PushButtonData pdata = new PushButtonData("命令按钮", "系统详情", path, className); PushButton pBtn = panel.AddItem(pdata) as PushButton; string className2 = "HStation.RevitDev.RevitDataExport.ValveSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Valve, className2); string imagePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "../../../../Data/Image/analysis.png"; pBtn.LargeImage = new BitmapImage(new Uri(imagePath));//32 * 32 pBtn.ToolTip = "Revit插件简介"; string className3 = "HStation.RevitDev.RevitDataExport.PipeSystem"; ribbon.CreateButton_PipeSystem(ribbonPanel, Enum.YWFamilyType.YWFT_Pipe, className3); //注册停靠面板 RegistDockablePanel(application); application.ControlledApplication.DocumentOpened += ControlledApplication_DocumentOpened; application.ControlledApplication.DocumentOpening += ControlledApplication_DocumentOpening; application.ControlledApplication.DocumentCreated += ControlledApplication_DocumentCreated; application.ControlledApplication.DocumentCreating += ControlledApplication_DocumentCreating; string className4 = "HStation.RevitDev.RevitDataExport.HeatExchangerSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Heat_Exchanger, className4); string className5 = "HStation.RevitDev.RevitDataExport.BlockerSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Blocker, className5); string className6 = "HStation.RevitDev.RevitDataExport.ShowerSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Shower, className6); string className7 = "HStation.RevitDev.RevitDataExport.ThreeJointSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Three_Joint, className7); string className8 = "HStation.RevitDev.RevitDataExport.FourJointSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Four_Joint, className8); string className9 = "HStation.RevitDev.RevitDataExport.WaterMeterSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Water_Meter, className9); string className10 = "HStation.RevitDev.RevitDataExport.WaterPoolSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Water_Pool, className10); string className11 = "HStation.RevitDev.RevitDataExport.WaterBoxSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Water_Box, className11); string className12 = "HStation.RevitDev.RevitDataExport.ElbowSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Elbow, className12); string className13 = "HStation.RevitDev.RevitDataExport.FireHydrantSystem"; ribbon.CreateButton_SystemAnalysis(ribbonPanel, Enum.YWFamilyType.YWFT_Fire_Hydrant, className13); } private void ControlledApplication_DocumentCreating(object sender, Autodesk.Revit.DB.Events.DocumentCreatingEventArgs e) private void RegistEvent() { Utility.DockPaneUtil.HideAllDockablePane(m_uiControlledApp); m_application.ControlledApplication.DocumentOpened += ControlledApplication_DocumentOpened; m_application.ControlledApplication.DocumentOpening += ControlledApplication_DocumentOpening; m_application.ControlledApplication.DocumentCreated += ControlledApplication_DocumentCreated; m_application.ControlledApplication.DocumentCreating += ControlledApplication_DocumentCreating; } private void ControlledApplication_DocumentOpening(object sender, Autodesk.Revit.DB.Events.DocumentOpeningEventArgs e) { Utility.DockPaneUtil.HideAllDockablePane(m_uiControlledApp); DockPaneUtil.HideAllDockablePane(m_application); } private void ControlledApplication_DocumentCreated(object sender, Autodesk.Revit.DB.Events.DocumentCreatedEventArgs e) { Utility.DockPaneUtil.HideAllDockablePane(m_uiControlledApp); DockPaneUtil.HideAllDockablePane(m_application); } private void ControlledApplication_DocumentOpened(object sender, Autodesk.Revit.DB.Events.DocumentOpenedEventArgs e) { Utility.DockPaneUtil.HideAllDockablePane(m_uiControlledApp); DockPaneUtil.HideAllDockablePane(m_application); } private void CreateRibbon_PipeSystemAnalysis(UIControlledApplication application) private void ControlledApplication_DocumentCreating(object sender, Autodesk.Revit.DB.Events.DocumentCreatingEventArgs e) { //1.创建RibbonTab选项卡页 application.CreateRibbonTab("义维定制"); //2.在RibbonTab选项卡页中创建RibbonPanel面板 RibbonPanel panel1 = application.CreateRibbonPanel("义维定制", "管道系统链路检测"); //3.命令按钮 //3.1指定程序集的名称、所使用的类名、程序集路径 //程序集路径--最好写成相对位置 string Path1 = Assembly.GetExecutingAssembly().Location; //程序集的名称、所使用的类名——"主程序集命名空间.主程序类名" 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添加图标 //可把图片资源加载入项目中,方便把图片的路径写成相对路径,并进行修改属性(图片的生成操作,改位:嵌入的资源) 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插件简介"; } private void RegistDockablePanel(UIControlledApplication uiApp) { foreach (var panelId in Common.GlobalResource.DockablePanelIds) { Guid guid = new Guid(panelId); DockablePaneId id = new DockablePaneId(guid); Wpf_FamilyPanel_Foundation panel = new Wpf_FamilyPanel_Foundation("C:\\Users\\zhangyk-c\\Desktop\\rfa"); uiApp.RegisterDockablePane(id, m_panelFoundationName, panel); } DockPaneUtil.HideAllDockablePane(m_application); } } } HStation.RevitDev/RevitDataExport/Plugin/Command.cs
@@ -1,9 +1,14 @@ using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Plumbing; using Autodesk.Revit.UI; using HStation.RevitDev.RevitDataExport.Common; using HStation.RevitDev.RevitDataExport.Enum; using HStation.RevitDev.RevitDataExport.Forms; using HStation.RevitDev.RevitDataExport.Utility; using Spire.AI.Api; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing.Drawing2D; using System.Windows.Controls; @@ -26,23 +31,187 @@ } } /// <summary> /// 水泵 /// </summary> [Transaction(TransactionMode.Manual)] public class PumpSystemAnalysis : IExternalCommand public class PumpSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Pump; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; foreach (var panelId in Common.GlobalResource.DockablePanelIds) { Guid guid = new Guid(panelId); DockablePaneId paneId = new DockablePaneId(guid); DockablePane pane = uiapp.GetDockablePane(paneId); pane.Show(); } ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 管道 /// </summary> [Transaction(TransactionMode.Manual)] public class PipeSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Pipe; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 阀门 /// </summary> [Transaction(TransactionMode.Manual)] public class ValveSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Valve; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 换热气 /// </summary> [Transaction(TransactionMode.Manual)] public class HeatExchangerSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Heat_Exchanger; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 闷头 /// </summary> [Transaction(TransactionMode.Manual)] public class BlockerSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Blocker; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 喷淋头 /// </summary> [Transaction(TransactionMode.Manual)] public class ShowerSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Shower; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 三通 /// </summary> [Transaction(TransactionMode.Manual)] public class ThreeJointSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Three_Joint; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 四通 /// </summary> [Transaction(TransactionMode.Manual)] public class FourJointSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Four_Joint; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 水表 /// </summary> [Transaction(TransactionMode.Manual)] public class WaterMeterSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Water_Meter; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 水库 /// </summary> [Transaction(TransactionMode.Manual)] public class WaterPoolSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Water_Pool; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 水箱 /// </summary> [Transaction(TransactionMode.Manual)] public class WaterBoxSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Water_Box; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 弯头 /// </summary> [Transaction(TransactionMode.Manual)] public class ElbowSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Elbow; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } /// <summary> /// 弯头 /// </summary> [Transaction(TransactionMode.Manual)] public class FireHydrantSystem : IExternalCommand { YWFamilyType m_type = YWFamilyType.YWFT_Fire_Hydrant; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { ExternalCommandUtils.ShowDockablePanel(commandData, m_type); return Result.Succeeded; } } public class WindowHandle : IWin32Window {