├── .gitignore ├── RevitPlugin ├── Resources │ ├── Images │ │ └── Icons │ │ │ ├── ifc_icon.jpg │ │ │ ├── pushbutton.png │ │ │ └── tooltipimage.png │ └── ResourceImage.cs ├── Models │ ├── Enums │ │ └── ErrorType.cs │ └── Error.cs ├── RevitPlugin.csproj.user ├── PluginAssembly.cs ├── UI │ ├── Revit │ │ ├── PushButtonDataModel.cs │ │ └── RevitPushButton.cs │ ├── MainWindow.xaml.cs │ └── MainWindow.xaml ├── App.cs ├── Services │ ├── Messenger │ │ ├── IMessenger.cs │ │ └── Messenger.cs │ └── DocumentManager.cs ├── SetupInterface.cs ├── Properties │ └── AssemblyInfo.cs ├── Utilities │ └── Extensions │ │ └── ExpressionExtensions.cs ├── Commands │ ├── JoinElements.cs │ └── ImportIfcCommand.cs ├── packages.config ├── app.config ├── Base │ ├── RelayCommand.cs │ └── ViewModelBase.cs ├── RevitPlugin.csproj └── ViewModels │ ├── MainWindowViewModel.cs │ └── MainWindowViewModel.Helpers.cs ├── IFCLoader ├── Data Model │ ├── Point.cs │ ├── Column.cs │ ├── FloorSlab.cs │ ├── Inclined.cs │ ├── Beam.cs │ ├── ColumnSt.cs │ ├── Brace.cs │ └── BeamSt.cs ├── Properties │ └── AssemblyInfo.cs ├── LoaderWin.cs ├── packages.config ├── App.config ├── src │ ├── IFC_Loader.cs │ └── Adapter.cs ├── LoaderWin.resx ├── Program.cs ├── IFC_Loader.csproj └── LoaderWin.Designer.cs ├── IFCtoREVIT.addin ├── README.md └── IFCtoREVIT.sln /.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | packages/ 3 | IFCLoader/.vs/ 4 | IFCLoader/bin/ 5 | IFCLoader/obj/ 6 | RevitPlugin/.vs/ 7 | RevitPlugin/bin/ 8 | RevitPlugin/obj/ -------------------------------------------------------------------------------- /RevitPlugin/Resources/Images/Icons/ifc_icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ibrahim5aad/ifc-to-revit-using-named-pipes/HEAD/RevitPlugin/Resources/Images/Icons/ifc_icon.jpg -------------------------------------------------------------------------------- /RevitPlugin/Resources/Images/Icons/pushbutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ibrahim5aad/ifc-to-revit-using-named-pipes/HEAD/RevitPlugin/Resources/Images/Icons/pushbutton.png -------------------------------------------------------------------------------- /RevitPlugin/Resources/Images/Icons/tooltipimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ibrahim5aad/ifc-to-revit-using-named-pipes/HEAD/RevitPlugin/Resources/Images/Icons/tooltipimage.png -------------------------------------------------------------------------------- /RevitPlugin/Models/Enums/ErrorType.cs: -------------------------------------------------------------------------------- 1 | namespace IFCtoRevit.Models 2 | { 3 | /// 4 | /// Enum ErrorType 5 | /// 6 | public enum ErrorType 7 | { 8 | Error, 9 | Warning, 10 | Info 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /RevitPlugin/RevitPlugin.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ProjectFiles 5 | 6 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/Point.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace IFCtoRevit.IFCLoader 8 | { 9 | [Serializable()] 10 | public struct Point 11 | { 12 | public double X; 13 | public double Y; 14 | public double Z; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/Column.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IFCtoRevit.IFCLoader 4 | { 5 | [Serializable()] 6 | public class Column 7 | { 8 | 9 | public Point Location { get; set; } 10 | 11 | public string Name { get; set; } 12 | 13 | public double BottomLevel { get; set; } 14 | 15 | public double TopLevel { get; set; } 16 | 17 | public double Width { get; set; } 18 | 19 | public double Depth { get; set; } 20 | 21 | public Point RefDirection { get; set; } 22 | 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/FloorSlab.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Media.Media3D; 4 | 5 | 6 | namespace IFCtoRevit.IFCLoader 7 | { 8 | [Serializable()] 9 | public class FloorSlab 10 | { 11 | public string Name { get; set; } 12 | public double Level { get; set; } 13 | public List Profile { get; set; } 14 | 15 | public Matrix3D Mat { get; set; } 16 | 17 | public Point RefDirection { get; set; } 18 | 19 | public Point Location { get; set; } 20 | public double Depth { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/Inclined.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IFCtoRevit.IFCLoader 4 | { 5 | [Serializable()] 6 | public class Inclined 7 | { 8 | public Point Location { get; set; } 9 | public Point RefDirection { get; set; } 10 | public Point Axis { get; set; } 11 | public double Length { get; set; } 12 | public string Name { get; set; } 13 | public double BottomLevel { get; set; } 14 | public double Width { get; set; } 15 | public double Depth { get; set; } 16 | 17 | // public double TopLevel { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/Beam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace IFCtoRevit.IFCLoader 8 | { 9 | [Serializable()] 10 | public class Beam 11 | { 12 | 13 | public string Name { get; set; } 14 | public double H { get; set; } 15 | public double B { get; set; } 16 | public double Length { get; set; } 17 | public Point Location { get; set; } 18 | public Point RefDirection { get; set; } 19 | public Point Axis { get; set; } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/ColumnSt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | 4 | namespace IFCtoRevit.IFCLoader 5 | { 6 | [Serializable()] 7 | public class ColumnSt 8 | { 9 | public Point Location { get; set; } 10 | public Point RefDirection { get; set; } 11 | public string Name { get; set; } 12 | public double BottomLevel { get; set; } 13 | public double TopLevel { get; set; } 14 | public double Width { get; set; } 15 | public double Depth { get; set; } 16 | public double FlangeTh { get; set; } 17 | public double WebTh { get; set; } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IFCtoREVIT.addin: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Import IFC Files 5 | IFCtoREVIT\RevitPlugin.dll 6 | 4BB49F2D-A774-4818-BEB8-EF95BB2CEA1F 7 | IFCtoRevit.App 8 | By: Marwa Mohamed and Ibrahim Saad 9 | AlwaysVisible 10 | Unknown 11 | 12 | Properly open IFC files exported from Etabs... 13 | 14 | 15 | -------------------------------------------------------------------------------- /IFCLoader/Data Model/Brace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IFCtoRevit.IFCLoader 4 | { 5 | [Serializable()] 6 | public class Brace 7 | { 8 | public Point Location { get; set; } 9 | public Point RefDirection { get; set; } 10 | public Point Axis { get; set; } 11 | public double Length { get; set; } 12 | public string Name { get; set; } 13 | public double BottomLevel { get; set; } 14 | public double Width { get; set; } 15 | public double Depth { get; set; } 16 | public double Thickness { get; set; } 17 | 18 | // public double TopLevel { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /RevitPlugin/PluginAssembly.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | 4 | namespace IFCtoRevit 5 | { 6 | public static class PluginAssembly 7 | { 8 | 9 | public static Assembly GetAssembly() 10 | { 11 | return Assembly.GetExecutingAssembly(); 12 | } 13 | 14 | // Assembly Location 15 | public static string GetAssemblyLocation() 16 | { 17 | return Assembly.GetExecutingAssembly().Location; 18 | } 19 | 20 | //Assembly Namespace 21 | public static string GetNamespace() 22 | { 23 | return typeof(PluginAssembly).Namespace + "."; 24 | } 25 | 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /IFCLoader/Data Model/BeamSt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace IFCtoRevit.IFCLoader 8 | { 9 | [Serializable()] 10 | public class BeamSt 11 | { 12 | 13 | public Point Location { get; set; } 14 | public Point RefDirection { get; set; } 15 | public Point Axis { get; set; } 16 | public string Name { get; set; } 17 | public double Length { get; set; } 18 | public double Width { get; set; } 19 | public double Depth { get; set; } 20 | public double FlangeTh { get; set; } 21 | public double WebTh { get; set; } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /RevitPlugin/Resources/ResourceImage.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media.Imaging; 2 | 3 | 4 | namespace IFCtoRevit 5 | { 6 | 7 | public static class ResourceImage 8 | { 9 | 10 | public static BitmapImage GetIcon(string name) 11 | { 12 | // Create the resource reader stream. 13 | var stream = PluginAssembly.GetAssembly().GetManifestResourceStream(PluginAssembly.GetNamespace() + "Resources.Images.Icons." + name); 14 | 15 | var image = new BitmapImage(); 16 | 17 | // Construct and return image. 18 | image.BeginInit(); 19 | image.StreamSource = stream; 20 | image.EndInit(); 21 | 22 | // Return constructed BitmapImage. 23 | return image; 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /RevitPlugin/UI/Revit/PushButtonDataModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Revit.UI; 3 | 4 | 5 | 6 | namespace IFCtoRevit.UI 7 | { 8 | 9 | /// 10 | /// Represents Revit push button data model. 11 | /// 12 | public class RevitPushButtonDataModel 13 | { 14 | #region public methods 15 | 16 | public string Label { get; set; } 17 | 18 | 19 | public RibbonPanel Panel { get; set; } 20 | 21 | public string CommandNamespacePath { get; set; } 22 | 23 | public string Tooltip { get; set; } 24 | 25 | public string IconImageName { get; set; } 26 | 27 | 28 | public string TooltipImageName { get; set; } 29 | 30 | #endregion 31 | 32 | #region constructor 33 | 34 | 35 | public RevitPushButtonDataModel() 36 | { 37 | 38 | } 39 | 40 | #endregion 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IFC to Revit using Named Pipes 2 | 3 | This is a sample application demonstrating how to use named pipes to establish a communication between a Revit plugin and a console application. 4 | The console application is an IFC files loader that is built on top of xBIM toolkit. Although this is a great demo how to use Named Pipe 5 | to establish a two-way communication with a Revit context, there was a technical necessity to follow this design. The necessity arises from 6 | a DLL collision that occurs when trying to use the xBIM toolkit inside Revit context directly; Microsoft.Extensions.Logging DLL is a common 7 | dependency between Revit and xBIM but each ecosystem has a different incompatible version. So, the solution was to run the IFC parsing/loading 8 | operations out-of-process with Revit and establish the communication through named pipes. 9 | 10 | ### Vidoe tutorial: 11 | [![Watch the video here!](https://user-images.githubusercontent.com/50090593/138493431-3d7768c4-d2fe-4f95-9ee2-447aea5c13b2.png)](https://www.youtube.com/watch?v=sGKHa4ep-xE) 12 | -------------------------------------------------------------------------------- /RevitPlugin/UI/Revit/RevitPushButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Autodesk.Revit.UI; 3 | 4 | namespace IFCtoRevit.UI 5 | { 6 | 7 | public static class RevitPushButton 8 | { 9 | #region public methods 10 | 11 | public static PushButton Create(RevitPushButtonDataModel data) 12 | { 13 | // The button name based on unique identifier. 14 | var btnDataName = Guid.NewGuid().ToString(); 15 | 16 | // Sets the button data. 17 | var btnData = new PushButtonData(btnDataName, data.Label, PluginAssembly.GetAssemblyLocation(), data.CommandNamespacePath) 18 | { 19 | ToolTip = data.Tooltip, 20 | LargeImage = ResourceImage.GetIcon(data.IconImageName), 21 | ToolTipImage = ResourceImage.GetIcon(data.TooltipImageName) 22 | }; 23 | 24 | // Return created button and host it on panel provided in required data model. 25 | return data.Panel.AddItem(btnData) as PushButton; 26 | } 27 | 28 | #endregion 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /RevitPlugin/App.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | 3 | namespace IFCtoRevit 4 | { 5 | public class App : IExternalApplication 6 | { 7 | /// 8 | /// Will execute your tasks when Autodesk Revit starts. 9 | /// 10 | /// A handle to the application being started. 11 | /// 12 | /// Indicates if the external application completes its work successfully. 13 | /// 14 | public Result OnStartup(UIControlledApplication application) 15 | { 16 | SetupInterface 17 | .Initialize(application); 18 | return Result.Succeeded; 19 | } 20 | 21 | 22 | /// 23 | /// Will excute your tasks when Autodesk Revit shuts down. 24 | /// 25 | /// A handle to the application being shut down. 26 | /// 27 | /// Indicates if the external application completes its work successfully. 28 | /// 29 | public Result OnShutdown(UIControlledApplication application) 30 | { 31 | return Result.Succeeded; 32 | 33 | } 34 | 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RevitPlugin/UI/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using IFCtoRevit.ViewModels; 2 | using System.Windows; 3 | 4 | namespace IFCtoRevit.UI.Windows 5 | { 6 | /// 7 | /// Interaction logic for MainWindow.xaml 8 | /// 9 | public partial class MainWindow : Window 10 | { 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public MainWindow() 16 | { 17 | DataContext = new MainWindowViewModel(); 18 | InitializeComponent(); 19 | } 20 | 21 | 22 | /// 23 | /// Gets or sets the current window. 24 | /// 25 | /// The current window. 26 | public static MainWindow CurrentWindow { get; set; } 27 | 28 | 29 | /// 30 | /// Handles the Click event of the btnClose control. 31 | /// 32 | /// The source of the event. 33 | /// The instance containing the event data. 34 | private void btnClose_Click(object sender, RoutedEventArgs e) 35 | { 36 | DataContext = null; 37 | Close(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /RevitPlugin/UI/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 23 |