diff --git a/IFC_Revit_Interop_VERSION_2018.sln b/IFC_Revit_Interop_VERSION_2018.sln new file mode 100644 index 0000000..52b973d --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IFC_Revit_Interop_VERSION_2018", "IFC_Revit_Interop_VERSION_2018\IFC_Revit_Interop_VERSION_2018.csproj", "{3916BB83-6282-4A88-B5A3-0FD79B1DF2E0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3916BB83-6282-4A88-B5A3-0FD79B1DF2E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3916BB83-6282-4A88-B5A3-0FD79B1DF2E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3916BB83-6282-4A88-B5A3-0FD79B1DF2E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3916BB83-6282-4A88-B5A3-0FD79B1DF2E0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportSession.cs b/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportSession.cs new file mode 100644 index 0000000..00cae32 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportSession.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; + +namespace ConsumerService.NetFramework.Model +{ + // Token: 0x02000004 RID: 4 + public class IfcExportSession + { + // Token: 0x17000001 RID: 1 + // (get) Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250 + // (set) Token: 0x06000002 RID: 2 RVA: 0x00002058 File Offset: 0x00000258 + public string Id { get; set; } + + // Token: 0x17000002 RID: 2 + // (get) Token: 0x06000003 RID: 3 RVA: 0x00002061 File Offset: 0x00000261 + // (set) Token: 0x06000004 RID: 4 RVA: 0x00002069 File Offset: 0x00000269 + public IfcExportSessionStatus SessionStatus { get; set; } + + // Token: 0x17000003 RID: 3 + // (get) Token: 0x06000005 RID: 5 RVA: 0x00002072 File Offset: 0x00000272 + // (set) Token: 0x06000006 RID: 6 RVA: 0x0000207A File Offset: 0x0000027A + public IfcExportStatus ExportStatus { get; set; } + + // Token: 0x17000004 RID: 4 + // (get) Token: 0x06000007 RID: 7 RVA: 0x00002083 File Offset: 0x00000283 + // (set) Token: 0x06000008 RID: 8 RVA: 0x0000208B File Offset: 0x0000028B + public string IfcUrl { get; set; } + + // Token: 0x17000005 RID: 5 + // (get) Token: 0x06000009 RID: 9 RVA: 0x00002094 File Offset: 0x00000294 + // (set) Token: 0x0600000A RID: 10 RVA: 0x0000209C File Offset: 0x0000029C + public string Message { get; set; } + + // Token: 0x17000006 RID: 6 + // (get) Token: 0x0600000B RID: 11 RVA: 0x000020A5 File Offset: 0x000002A5 + // (set) Token: 0x0600000C RID: 12 RVA: 0x000020AD File Offset: 0x000002AD + public string ResultUrl { get; set; } + + // Token: 0x17000007 RID: 7 + // (get) Token: 0x0600000D RID: 13 RVA: 0x000020B6 File Offset: 0x000002B6 + // (set) Token: 0x0600000E RID: 14 RVA: 0x000020BE File Offset: 0x000002BE + public Dictionary ExternalArguments { get; set; } + + // Token: 0x17000008 RID: 8 + // (get) Token: 0x0600000F RID: 15 RVA: 0x000020C7 File Offset: 0x000002C7 + // (set) Token: 0x06000010 RID: 16 RVA: 0x000020CF File Offset: 0x000002CF + public DateTime CreateTime { get; set; } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportSessionStatus.cs b/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportSessionStatus.cs new file mode 100644 index 0000000..6bb89d2 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportSessionStatus.cs @@ -0,0 +1,17 @@ +using System; + +namespace ConsumerService.NetFramework.Model +{ + // Token: 0x02000002 RID: 2 + public enum IfcExportSessionStatus + { + // Token: 0x04000002 RID: 2 + None, + // Token: 0x04000003 RID: 3 + Received, + // Token: 0x04000004 RID: 4 + Processing, + // Token: 0x04000005 RID: 5 + Done + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportStatus.cs b/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportStatus.cs new file mode 100644 index 0000000..7f2ece6 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/ConsumerService/NetFramework/Model/IfcExportStatus.cs @@ -0,0 +1,15 @@ +using System; + +namespace ConsumerService.NetFramework.Model +{ + // Token: 0x02000003 RID: 3 + public enum IfcExportStatus + { + // Token: 0x04000007 RID: 7 + None, + // Token: 0x04000008 RID: 8 + Success, + // Token: 0x04000009 RID: 9 + Fail + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/App_IFCExporter_StartUp.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/App_IFCExporter_StartUp.cs new file mode 100644 index 0000000..fe9696a --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/App_IFCExporter_StartUp.cs @@ -0,0 +1,697 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.IO.Pipes; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using Autodesk.Revit.ApplicationServices; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using Autodesk.Revit.DB.Events; +using Autodesk.Revit.UI; +using Autodesk.Revit.UI.Events; +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser; +using IFC_ExcelReport; +using IFC_Revit_Interop.NetCore; +using IFC_Revit_Interop.Utils; +using Microsoft.WindowsAPICodePack.Dialogs; +using Microsoft.WindowsAPICodePack.Dialogs.Controls; +using Newtonsoft.Json; +using RunCompress; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000005 RID: 5 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + public class App_IFCExporter_StartUp : IExternalApplication + { + // Token: 0x06000012 RID: 18 RVA: 0x000020E0 File Offset: 0x000002E0 + public Result OnShutdown(UIControlledApplication application) + { + return 0; + } + + // Token: 0x06000013 RID: 19 RVA: 0x000020F0 File Offset: 0x000002F0 + public Result OnStartup(UIControlledApplication application) + { + App_IFCExporter_StartUp.log.Write("APP", "OnStartup"); + this.uictrlapp = application; + try + { + App_Ribbon.InitRibbon(application); + App_IFCExporter_StartUp.log.Write("APP", "Ribbon Added"); + } + catch (Exception ex) + { + App_IFCExporter_StartUp.log.WriteException("ERR_APP", ex); + } + App_IFCExporter_StartUp.log.Write("APP", "Command Binded"); + if (Settings_IFC.LISTEN_TO_SERVER == "true") + { + application.ControlledApplication.ApplicationInitialized += this.OnApplicationInitialized; + this.uictrlapp.DialogBoxShowing += this.OnApplicationDialogBoxShowing; + } + else + { + App_IFCExporter_StartUp.log.Write("APP", "EXIT_NO_REMOTE"); + } + return 0; + } + + // Token: 0x06000014 RID: 20 RVA: 0x000021C4 File Offset: 0x000003C4 + private void OnApplicationInitialized(object sender, ApplicationInitializedEventArgs e) + { + App_IFCExporter_StartUp.log.Write("APP", "STARTED"); + App_IFCExporter_StartUp.log.Write("APP", "SERVER_ONTEST " + App_IFCExporter_StartUp.SERVER_ONTEST.ToString()); + int id = Process.GetCurrentProcess().Id; + this.pipe = new NamedPipeClientStream(".", "ifcexport_" + id.ToString(), PipeDirection.InOut, PipeOptions.None); + App_IFCExporter_StartUp.log.Write("APP", "Create pipe ifcexport_" + id.ToString()); + try + { + this.pipe.Connect(500); + App_IFCExporter_StartUp.log.Write("APP", "CONNECTED_ON_PIPE"); + Application application = sender as Application; + application.FailuresProcessing += this.OnApplicationFailuresProcessing; + App_IFCExporter_StartUp.log.Write("APP", "DIALOG_EVENT_BOUND"); + using (BinaryWriter binaryWriter = new BinaryWriter(this.pipe, Encoding.UTF8, true)) + { + using (BinaryReader binaryReader = new BinaryReader(this.pipe, Encoding.UTF8, true)) + { + IfcExporterProcessMessage ifcExporterProcessMessage = JsonConvert.DeserializeObject(binaryReader.ReadString()); + try + { + string text = null; + if (ifcExporterProcessMessage.Arguments.ContainsKey("modelPath")) + { + text = ifcExporterProcessMessage.Arguments["modelPath"].ToString(); + } + if (ifcExporterProcessMessage.Arguments.ContainsKey("exportViewPack") && ifcExporterProcessMessage.Arguments["exportViewPack"].ToString().ToLower() == "true") + { + App_IFCExporter_StartUp.EXPORT_VIEWPACK = true; + } + if (text == null || text == "") + { + App_IFCExporter_StartUp.log.Write("APP", "EXIT_NULL_FILE_URL"); + ifcExporterProcessMessage.Status = IfcExporterProgcessStatus.START; + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Fail; + ifcExporterProcessMessage.Arguments = new Dictionary(); + ifcExporterProcessMessage.Arguments.Add("exception", "EXIT_NULL_FILE_URL"); + binaryWriter.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + else + { + App_IFCExporter_StartUp.log.Write("APP", text); + Document document = new UIApplication(application).OpenAndActivateDocument(text).Document; + App_IFCExporter_StartUp.log.Write("APP", "OPENED"); + string text2 = ifcExporterProcessMessage.Arguments["outDir"].ToString(); + string text3 = ifcExporterProcessMessage.Arguments["fileName"].ToString(); + if (ifcExporterProcessMessage.Arguments.ContainsKey("OnlyQueryViews") && ifcExporterProcessMessage.Arguments["OnlyQueryViews"] == "true") + { + App_IFCExporter_StartUp.log.Write("APP", "Only Query View Names"); + List list = (from v in Command_ViewExport.GetAllViews(document, true) + select v.Name).ToList(); + if (ifcExporterProcessMessage.Arguments == null) + { + ifcExporterProcessMessage.Arguments = new Dictionary(); + } + ifcExporterProcessMessage.Arguments["ViewNames"] = JsonConvert.SerializeObject(list); + ifcExporterProcessMessage.Status = IfcExporterProgcessStatus.END; + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Success; + binaryWriter.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + else if (ifcExporterProcessMessage.Arguments.ContainsKey("OnlyQueryLinks") && ifcExporterProcessMessage.Arguments["OnlyQueryLinks"] == "true") + { + App_IFCExporter_StartUp.log.Write("APP", "Only Query File Links"); + Result linkFileInfo = LinkedFileManager.GetLinkFileInfo(document, ifcExporterProcessMessage.Arguments["LinkSavePath"]); + ifcExporterProcessMessage.Status = IfcExporterProgcessStatus.END; + ifcExporterProcessMessage.TaskStatus = ((linkFileInfo == null) ? CommonTaskStatus.Success : CommonTaskStatus.Fail); + binaryWriter.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + else + { + IFCExportOptions ifcexportOptions = new IFCExportOptions(); + App_IFCExporter_StartUp.log.Write("APP", "FILE_VERSION " + ifcExporterProcessMessage.Arguments["fileVersion"].ToString()); + if (ifcExporterProcessMessage.Arguments["fileVersion"].ToString().ToUpper().Contains("IFC4")) + { + ifcexportOptions.FileVersion = App_IFCExporter_StartUp.V_IFC4; + } + else + { + ifcexportOptions.FileVersion = App_IFCExporter_StartUp.V_IFC2X3; + } + ifcexportOptions.ExportBaseQuantities = Convert.ToBoolean(ifcExporterProcessMessage.Arguments["exportBaseQuantities"]); + ifcexportOptions.AddOption("ExportInternalRevitPropertySets", true.ToString()); + ifcexportOptions.AddOption("ExportIFCCommonPropertySets", true.ToString()); + if (ifcExporterProcessMessage.Arguments.ContainsKey("messageId")) + { + string text4 = ifcExporterProcessMessage.Arguments["messageId"].ToString(); + App_IFCExporter_StartUp.log.Write("APP", "MessageId " + text4); + } + ExternalEventHandler_Export externalEventHandler_Export = new ExternalEventHandler_Export(document, this.pipe, text2, text3, ifcexportOptions, ifcExporterProcessMessage); + ExternalEvent externalEvent = ExternalEvent.Create(externalEventHandler_Export); + FormExportCountdown formExportCountdown = new FormExportCountdown(externalEventHandler_Export, externalEvent); + formExportCountdown.Show(); + formExportCountdown.StartCountdown(); + } + } + } + catch (Exception ex) + { + App_IFCExporter_StartUp.log.WriteException("APP_ERR_2", ex); + ifcExporterProcessMessage.Status = IfcExporterProgcessStatus.START; + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Fail; + ifcExporterProcessMessage.Arguments = new Dictionary(); + ifcExporterProcessMessage.Arguments.Add("exception", "APP_ERR " + ex.GetType().FullName + "\t" + ex.Message); + binaryWriter.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + } + } + } + catch (TimeoutException ex2) + { + this.uictrlapp.DialogBoxShowing -= this.OnApplicationDialogBoxShowing; + App_IFCExporter_StartUp.log.Write("APP", ex2.Message); + App_IFCExporter_StartUp.log.Write("APP", "EXIT_NO_PIPE"); + } + catch (Exception ex3) + { + App_IFCExporter_StartUp.log.WriteException("APP_PIPE_ERR", ex3); + } + } + + // Token: 0x06000015 RID: 21 RVA: 0x00002804 File Offset: 0x00000A04 + public void OnApplicationDialogBoxShowing(object sender, DialogBoxShowingEventArgs args) + { + if (App_IFCExporter_StartUp.SERVER_ON || App_IFCExporter_StartUp.SERVER_ONTEST) + { + TaskDialogShowingEventArgs taskDialogShowingEventArgs = args as TaskDialogShowingEventArgs; + if (taskDialogShowingEventArgs != null) + { + string empty = string.Empty; + bool flag = false; + int num = 0; + if (taskDialogShowingEventArgs.DialogId.Equals("TaskDialog_Update_Resources")) + { + flag = true; + num = 1001; + } + if (taskDialogShowingEventArgs.DialogId.Equals("TaskDialog_Unresolved_References")) + { + flag = true; + num = 1002; + } + if (taskDialogShowingEventArgs.DialogId.Equals("TaskDialog_Missing_Third_Party_Updaters")) + { + flag = true; + num = 1002; + } + if (taskDialogShowingEventArgs.DialogId.Equals("TaskDialog_Missing_Third_Party_Updater")) + { + flag = true; + num = 1002; + } + if (taskDialogShowingEventArgs.DialogId.Equals("TaskDialog_Local_Changes_Not_Synchronized_With_Central")) + { + flag = true; + num = 1002; + } + if (taskDialogShowingEventArgs.DialogId.Equals("TaskDialog_Default_Family_Template_File_Invalid")) + { + flag = true; + num = 8; + } + if (flag) + { + taskDialogShowingEventArgs.OverrideResult(num); + } + else + { + taskDialogShowingEventArgs.OverrideResult(8); + } + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAG", string.Concat(new string[] + { + "TaskDialog DialogId ", + taskDialogShowingEventArgs.DialogId, + "\tConfirmed ", + flag.ToString(), + "\tMessage ", + taskDialogShowingEventArgs.Message + })); + return; + } + } + else + { + MessageBoxShowingEventArgs messageBoxShowingEventArgs = args as MessageBoxShowingEventArgs; + if (messageBoxShowingEventArgs != null) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAG", "TaskDialog DialogId " + messageBoxShowingEventArgs.DialogId + "\tMessage " + messageBoxShowingEventArgs.Message); + } + messageBoxShowingEventArgs.OverrideResult(8); + return; + } + if (args != null) + { + App_IFCExporter_StartUp.log.Write("DIAG", "DialogWithArgs DialogId " + args.DialogId); + args.OverrideResult(8); + return; + } + App_IFCExporter_StartUp.log.Write("DIAG", "not available"); + if (this.pipe != null) + { + IfcExporterProcessMessage ifcExporterProcessMessage = new IfcExporterProcessMessage + { + Status = IfcExporterProgcessStatus.START, + TaskStatus = CommonTaskStatus.Fail + }; + using (BinaryWriter binaryWriter = new BinaryWriter(this.pipe, Encoding.UTF8, true)) + { + binaryWriter.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + } + } + } + } + + // Token: 0x06000016 RID: 22 RVA: 0x00002A20 File Offset: 0x00000C20 + public void OnApplicationFailuresProcessing(object sender, FailuresProcessingEventArgs args) + { + if (App_IFCExporter_StartUp.SERVER_ON || App_IFCExporter_StartUp.SERVER_ONTEST) + { + FailuresAccessor failuresAccessor = args.GetFailuresAccessor(); + FailureHandlingOptions failureHandlingOptions = failuresAccessor.GetFailureHandlingOptions(); + failureHandlingOptions.SetClearAfterRollback(true); + failuresAccessor.SetFailureHandlingOptions(failureHandlingOptions); + List list = failuresAccessor.GetFailureMessages().ToList(); + if (list.Count == 0) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "No failure, continue."); + } + args.SetProcessingResult(0); + return; + } + foreach (FailureMessageAccessor failureMessageAccessor in list) + { + try + { + FailureSeverity severity = failureMessageAccessor.GetSeverity(); + if (severity > (FailureSeverity)1) + { + if ((int)severity - 2 <= 1) + { + if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)2)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'CreateElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)2); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)3)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'DeleteElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)3); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)4)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'SkipElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)4); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)5)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'MoveElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)5); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)6)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'FixElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)6); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)7)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'DetachElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)7); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)8)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'QuitEditMode'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)8); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)9)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'UnlockConstraints'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)9); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)10)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'SetValue'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)10); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)11)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'SaveDocument'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)11); + } + else if (failuresAccessor.IsFailureResolutionPermitted(failureMessageAccessor, (FailureResolutionType)12)) + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution 'ShowElements'\t" + failureMessageAccessor.GetDescriptionText()); + } + failureMessageAccessor.SetCurrentResolutionType((FailureResolutionType)12); + } + else + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Failure resolution not set\t" + failureMessageAccessor.GetDescriptionText()); + } + failuresAccessor.ResolveFailure(failureMessageAccessor); + } + } + else + { + if (App_IFCExporter_StartUp.SERVER_ONTEST) + { + App_IFCExporter_StartUp.log.Write("DIAGF", "Delete warning.\t" + failureMessageAccessor.GetDescriptionText()); + } + failuresAccessor.DeleteWarning(failureMessageAccessor); + } + } + catch (Exception ex) + { + App_IFCExporter_StartUp.log.WriteException("ERR_DIAGF", ex); + } + } + args.SetProcessingResult((FailureProcessingResult)1); + } + } + + // Token: 0x06000017 RID: 23 RVA: 0x00002E44 File Offset: 0x00001044 + public void OnIFCExport(object sender, CommandEventArgs args) + { + App_IFCExporter_StartUp.DoExport_WithForm(sender as UIApplication); + } + + // Token: 0x06000018 RID: 24 RVA: 0x00002E54 File Offset: 0x00001054 + internal static void DoExport_WithForm(UIApplication uiApp) + { + try + { + Document document = uiApp.ActiveUIDocument.Document; + CommonSaveFileDialog commonSaveFileDialog = new CommonSaveFileDialog(); + commonSaveFileDialog.OverwritePrompt = true; + commonSaveFileDialog.DefaultExtension = ".ifc"; + commonSaveFileDialog.Title = "导出IFC"; + commonSaveFileDialog.Filters.Add(new CommonFileDialogFilter("IFC4", "*.ifc")); + string text = null; + if (!string.IsNullOrEmpty(document.PathName)) + { + commonSaveFileDialog.InitialDirectory = Path.GetDirectoryName(document.PathName); + commonSaveFileDialog.DefaultFileName = Path.GetFileNameWithoutExtension(document.PathName); + if (File.Exists(document.PathName)) + { + text = ((double)new FileInfo(document.PathName).Length / 1024.0 / 1024.0).ToString(); + } + } + CommonFileDialogCheckBox commonFileDialogCheckBox = new CommonFileDialogCheckBox("compress", "压缩IFC", true); + commonSaveFileDialog.Controls.Add(commonFileDialogCheckBox); + CommonFileDialogCheckBox commonFileDialogCheckBox2 = new CommonFileDialogCheckBox("report", "简化报告", true); + commonSaveFileDialog.Controls.Add(commonFileDialogCheckBox2); + CommonFileDialogCheckBox commonFileDialogCheckBox3 = new CommonFileDialogCheckBox("texture", "添加纹理", false); + commonSaveFileDialog.Controls.Add(commonFileDialogCheckBox3); + CommonFileDialogComboBox commonFileDialogComboBox = new CommonFileDialogComboBox(); + commonFileDialogComboBox.Items.Add(new CommonFileDialogComboBoxItem("原点: 场地测量点")); + commonFileDialogComboBox.Items.Add(new CommonFileDialogComboBoxItem("原点: 项目基点")); + commonFileDialogComboBox.SelectedIndex = 1; + commonSaveFileDialog.Controls.Add(commonFileDialogComboBox); + commonSaveFileDialog.EnsureValidNames = true; + commonSaveFileDialog.EnsurePathExists = true; + if (commonSaveFileDialog.ShowDialog() != CommonFileDialogResult.Ok) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "CANCEL"); + } + else + { + string fileName = commonSaveFileDialog.FileName; + string directoryName = Path.GetDirectoryName(fileName); + string text2 = Path.GetFileName(fileName); + if (text2.EndsWith(".ifc")) + { + text2 = text2.Substring(0, text2.Length - 4); + } + IFCExportOptions ifcexportOptions = new IFCExportOptions(); + ifcexportOptions.AddOption("ExportInternalRevitPropertySets", true.ToString()); + ifcexportOptions.AddOption("ExportIFCCommonPropertySets", true.ToString()); + ifcexportOptions.ExportBaseQuantities = true; + ifcexportOptions.AddOption("SitePlacement", (commonFileDialogComboBox.SelectedIndex + 1).ToString()); + ifcexportOptions.FileVersion = App_IFCExporter_StartUp.V_IFC4; + DateTime dateTime = DateTime.Now; + ExportProcess exportProcess = new ExportProcess(document); + Utils_SendMessage.CreateProgressBar(Utils_Process.StartProcess(Settings_IFC.RUN_ProgressBar_PATH, new string[] { Process.GetCurrentProcess().Id.ToString() })); + bool flag = exportProcess.DoExport(directoryName, text2, ifcexportOptions); + DateTime dateTime2 = DateTime.Now; + TimeSpan timeSpan = dateTime2 - dateTime; + dateTime = dateTime2; + string text3 = Path.Combine(directoryName, text2); + string text4 = text3 + ".ifc"; + if (File.Exists(text4 + ".log")) + { + File.Delete(text4 + ".log"); + } + if (File.Exists(text4)) + { + string text5 = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + text5 = text5.Substring(0, text5.LastIndexOf('.')); + STEPModel stepmodel = new STEPModel(text4); + stepmodel.Schema = EXPSchema.GetEXPSchema(stepmodel.SchemaVersion.First()); + ISTEPEntity istepentity = stepmodel.GetEntitiesByType("IFCORGANIZATION", true).FirstOrDefault(); + if (istepentity != null) + { + istepentity.Data.SetString(1, "SZ-IFC转换插件" + text5); + } + ISTEPEntity istepentity2 = stepmodel.GetEntitiesByType("IFCAPPLICATION", true).FirstOrDefault(); + if (istepentity2 != null) + { + istepentity2.Data.SetString(1, text5); + istepentity2.Data.SetString(2, "SZ-IFC转换插件"); + istepentity2.Data.SetString(3, ""); + } + try + { + TrimClassification.TrimClassificationInModel(stepmodel); + } + catch (Exception ex) + { + App_IFCExporter_StartUp.log.WriteException("Classification_Delete_ERR", ex); + } + stepmodel.Write(text4); + } + if (flag && App_IFCExporter_StartUp.DO_STAT) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "START_STAT"); + Utils_SendMessage.UpdateProgressUI("Report"); + Dictionary dictionary = new Dictionary(); + if (text != null) + { + dictionary["RVT文件大小(MB)"] = text; + } + dictionary["RVT-IFC导出用时(秒)"] = timeSpan.TotalSeconds.ToString(); + IModel model = exportProcess.LoadExportedIFC(text4, ref dictionary); + if (new FilteredElementCollector(document).OfClass(typeof(Wire)).Count() > 0) + { + exportProcess.DoPostFix(document, model, text4); + } + exportProcess.DoStatistic(model, commonFileDialogCheckBox2.IsChecked, ref dictionary); + dateTime2 = DateTime.Now; + TimeSpan timeSpan2 = dateTime2 - dateTime; + dictionary["RVT-IFC统计用时(秒)"] = timeSpan2.TotalSeconds.ToString(); + XlsxReport.WriteReport(text3 + ".ifc.xlsx", dictionary, "-", text2, dateTime2.ToString(), true, commonFileDialogCheckBox2.IsChecked); + } + Utils_SendMessage.ExitProgressBar(); + if (flag && commonFileDialogCheckBox.IsChecked) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "START_COMP"); + try + { + string[] array = new string[] + { + text4, + text4, + App_IFCExporter_StartUp.log.path + }; + Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_COMPRESS_PATH, array); + } + catch (Exception ex2) + { + App_IFCExporter_StartUp.log.WriteException("COMPRESS_ERR", ex2); + } + } + if (flag && commonFileDialogCheckBox3.IsChecked) + { + GC.Collect(); + App_IFCExporter_StartUp.log.Write("EXPORT", "START_Texture"); + try + { + string text6 = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName().Replace(".", "")); + string text7 = text6 + ".obj"; + string text8 = text6 + ".mtl"; + string text9 = Path.Combine(Path.GetDirectoryName(text7), "textures"); + if (Command_ObjExport.ObjExport(document, text7, text9) == null) + { + App_IFCExporter_StartUp.log.Write("Texture", "OBJ Export Success."); + string[] array2 = new string[] + { + text7, + text4, + App_IFCExporter_StartUp.log.path + }; + Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_TEXTURE_PATH, array2); + Thread.Sleep(500); + try + { + if (File.Exists(text7)) + { + File.Delete(text7); + } + if (File.Exists(text8)) + { + File.Delete(text8); + } + } + catch + { + } + } + } + catch (Exception ex3) + { + App_IFCExporter_StartUp.log.WriteException("TEXTURE_ERR", ex3); + } + } + App_IFCExporter_StartUp.log.Write("EXPORT", "END"); + } + } + catch (Exception ex4) + { + App_IFCExporter_StartUp.log.WriteException("EXPORT", ex4); + } + } + + // Token: 0x06000019 RID: 25 RVA: 0x00003534 File Offset: 0x00001734 + private static bool RunComperssInExe(CompMsg _msg) + { + string text = "IFCCOMP_"; + string text2 = JsonConvert.SerializeObject(_msg); + string run_COMPRESS_PATH = Settings_IFC.RUN_COMPRESS_PATH; + if (!File.Exists(run_COMPRESS_PATH)) + { + App_IFCExporter_StartUp.log.Write("IFCCOMP_ERR", "exit without exe."); + return false; + } + using (Process process = new Process()) + { + process.StartInfo.FileName = run_COMPRESS_PATH; + process.StartInfo.CreateNoWindow = true; + process.StartInfo.UseShellExecute = false; + process.Start(); + text += process.Id.ToString(); + } + PipeServerControl pipeServerControl = new PipeServerControl(text); + if (pipeServerControl.CreatePipe()) + { + pipeServerControl.WritePipe(text2); + if (pipeServerControl.ReadPipe(out text2)) + { + if (text2 == "OK") + { + pipeServerControl.ClosePipe(); + return true; + } + App_IFCExporter_StartUp.log.Write("IFCCOMP_ERR", text2); + } + else + { + App_IFCExporter_StartUp.log.Write("IFCCOMP_ERR", "fail read."); + } + pipeServerControl.ClosePipe(); + } + else + { + App_IFCExporter_StartUp.log.Write("IFCCOMP_ERR", "err create pipe."); + } + return false; + } + + // Token: 0x04000012 RID: 18 + private const bool BIND_DEFAULT_EXPORT_DIALOG = false; + + // Token: 0x04000013 RID: 19 + public static bool SERVER_ON = true; + + // Token: 0x04000014 RID: 20 + public static bool SERVER_ONTEST = Settings_IFC.LOG_SERVER_ONTEST == "true"; + + // Token: 0x04000015 RID: 21 + internal static Log log = new Log(Settings_IFC.LOG_PATH, true); + + // Token: 0x04000016 RID: 22 + public static bool DO_STAT = Settings_IFC.DO_STAT == "true"; + + // Token: 0x04000017 RID: 23 + public static bool EXPORT_VIEWPACK = false; + + // Token: 0x04000018 RID: 24 + private NamedPipeClientStream pipe; + + // Token: 0x04000019 RID: 25 + private UIControlledApplication uictrlapp; + + // Token: 0x0400001A RID: 26 + public static IFCVersion V_IFC4 = (IFCVersion)25; + + // Token: 0x0400001B RID: 27 + public static IFCVersion V_IFC2X3 = (IFCVersion)21; + + // Token: 0x0400001C RID: 28 + private AddInCommandBinding m_ifcCommandBinding; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/App_Ribbon.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/App_Ribbon.cs new file mode 100644 index 0000000..3026cd9 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/App_Ribbon.cs @@ -0,0 +1,50 @@ +using System; +using System.IO; +using System.Windows.Media.Imaging; + +using Autodesk.Revit.UI; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000006 RID: 6 + internal static class App_Ribbon + { + // Token: 0x17000009 RID: 9 + // (get) Token: 0x0600001C RID: 28 RVA: 0x000036BF File Offset: 0x000018BF + public static string SoftWareName { get; } = "CBIMS RvtToolkit"; + + // Token: 0x0600001D RID: 29 RVA: 0x000036C8 File Offset: 0x000018C8 + internal static void InitRibbon(UIControlledApplication application) + { + string text = "SZ-IFC转换插件"; + string text2 = "SZ-IFC"; + application.CreateRibbonTab(text); + RibbonPanel ribbonPanel = application.CreateRibbonPanel(text, text2); + PushButton pushButton = ribbonPanel.AddItem(new PushButtonData("pbExport", "导出SZ-IFC", Settings_IFC.ADDIN_PATH, "IFC_Revit_Interop.Command_IFCExport")) as PushButton; + pushButton.LargeImage = new BitmapImage(new Uri(Path.Combine(Settings_IFC.DIRECTORY, "i_IFC_export.png"), UriKind.Absolute)); + pushButton.AvailabilityClassName = "IFC_Revit_Interop.ZeroDocAvailability"; + #region 添加 + PushButton pushButton1 = ribbonPanel.AddItem(new PushButtonData("pbExportBatch", "批量导出SZ-IFC", Settings_IFC.ADDIN_PATH, "IFC_Revit_Interop.Command_IFCBatchExport")) as PushButton; + pushButton1.LargeImage = new BitmapImage(new Uri(Path.Combine(Settings_IFC.DIRECTORY, "i_IFC_export.png"), UriKind.Absolute)); + pushButton1.AvailabilityClassName = "IFC_Revit_Interop.ZeroDocAvailability"; + #endregion + string text3 = "LowVersion"; + if ("2018".Equals("2021") || "2018".Equals("2022")) + { + text3 = "HighVersion"; + } + (ribbonPanel.AddItem(new PushButtonData("pbCheck", "模型预检", Path.Combine(Settings_IFC.DIRECTORY, "RevitMVD.Command." + text3 + ".dll"), "RevitMVD.Command.Command_MVDPreCheck")) as PushButton).LargeImage = new BitmapImage(new Uri(Path.Combine(Settings_IFC.DIRECTORY, "i_Precheck.png"), UriKind.Absolute)); + string text4 = Path.Combine(Settings_IFC.DIRECTORY, "Toolkit_Filter.dll"); + if (File.Exists(text4)) + { + PushButton pushButton2 = ribbonPanel.AddItem(new PushButtonData("pbLookup", "批量查找构件", text4, "IFC_Revit_Interop.Toolkit.Filter.Command_LookupIds")) as PushButton; + pushButton2.LargeImage = new BitmapImage(new Uri(Path.Combine(Settings_IFC.DIRECTORY, "i_Lookup.png"), UriKind.Absolute)); + pushButton2.ToolTip = "通过批量输入构件ID号,快速找到对应的构件。"; + } + text4 = Path.Combine(Settings_IFC.DIRECTORY, "Toolkit_ParaIO.dll"); + } + + // Token: 0x0400001D RID: 29 + public const string YEAR = "2018"; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_IFCBatchExport.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_IFCBatchExport.cs new file mode 100644 index 0000000..e7198b7 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_IFCBatchExport.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Windows.Forms; + +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using Autodesk.Revit.UI; + +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser; + +using IFC_ExcelReport; + +using IFC_Revit_Interop.NetCore; +using IFC_Revit_Interop.Utils; + +using Microsoft.WindowsAPICodePack.Dialogs; +using Microsoft.WindowsAPICodePack.Dialogs.Controls; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000008 RID: 8 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_IFCBatchExport : IExternalCommand + { + // Token: 0x1700000A RID: 10 + // (get) Token: 0x06000021 RID: 33 RVA: 0x0000385C File Offset: 0x00001A5C + public static string DefaultLicenseDir + { + get + { + string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cbims\\"); + if (!Directory.Exists(text)) + { + Directory.CreateDirectory(text); + } + return text; + } + } + + // Token: 0x06000022 RID: 34 RVA: 0x0000388A File Offset: 0x00001A8A + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + DoExport_WithForm(commandData.Application); + return 0; + } + internal static void DoExport_WithForm(UIApplication uiApp) + { + try + { + CommonOpenFileDialog commonOpenFileDialog = new CommonOpenFileDialog() { Multiselect = true }; + commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("Revit文件", "*.rvt")); + CommonFileDialogCheckBox commonFileDialogCheckBox = new CommonFileDialogCheckBox("compress", "压缩IFC", true); + commonOpenFileDialog.Controls.Add(commonFileDialogCheckBox); + CommonFileDialogCheckBox commonFileDialogCheckBox2 = new CommonFileDialogCheckBox("report", "简化报告", true); + commonOpenFileDialog.Controls.Add(commonFileDialogCheckBox2); + CommonFileDialogCheckBox commonFileDialogCheckBox3 = new CommonFileDialogCheckBox("texture", "添加纹理", false); + commonOpenFileDialog.Controls.Add(commonFileDialogCheckBox3); + CommonFileDialogComboBox commonFileDialogComboBox = new CommonFileDialogComboBox(); + commonFileDialogComboBox.Items.Add(new CommonFileDialogComboBoxItem("原点: 场地测量点")); + commonFileDialogComboBox.Items.Add(new CommonFileDialogComboBoxItem("原点: 项目基点")); + commonFileDialogComboBox.SelectedIndex = 1; + commonOpenFileDialog.Controls.Add(commonFileDialogComboBox); + commonOpenFileDialog.EnsureValidNames = true; + commonOpenFileDialog.EnsurePathExists = true; + var result = commonOpenFileDialog.ShowDialog(); + if (result == CommonFileDialogResult.Cancel || result == CommonFileDialogResult.None) + { + return; + } + + foreach (var file in commonOpenFileDialog.FileNames) + { + Document document = uiApp.Application.OpenDocumentFile(file); + string text = null; + if (!string.IsNullOrEmpty(document.PathName)) + { + commonOpenFileDialog.InitialDirectory = Path.GetDirectoryName(document.PathName); + commonOpenFileDialog.DefaultFileName = Path.GetFileNameWithoutExtension(document.PathName); + if (File.Exists(document.PathName)) + { + text = ((double)new FileInfo(document.PathName).Length / 1024.0 / 1024.0).ToString(); + } + } + + //string fileName = commonOpenFileDialog.FileName; + string fileName = Path.Combine(commonOpenFileDialog.InitialDirectory, commonOpenFileDialog.DefaultFileName); + + string directoryName = Path.GetDirectoryName(fileName); + string text2 = Path.GetFileName(fileName); + if (text2.EndsWith(".ifc")) + { + text2 = text2.Substring(0, text2.Length - 4); + } + IFCExportOptions ifcexportOptions = new IFCExportOptions(); + ifcexportOptions.AddOption("ExportInternalRevitPropertySets", true.ToString()); + ifcexportOptions.AddOption("ExportIFCCommonPropertySets", true.ToString()); + ifcexportOptions.ExportBaseQuantities = true; + ifcexportOptions.AddOption("SitePlacement", (commonFileDialogComboBox.SelectedIndex + 1).ToString()); + ifcexportOptions.FileVersion = App_IFCExporter_StartUp.V_IFC4; + DateTime dateTime = DateTime.Now; + ExportProcess exportProcess = new ExportProcess(document); + //Utils_SendMessage.CreateProgressBar(Utils_Process.StartProcess(Settings_IFC.RUN_ProgressBar_PATH, new string[] { Process.GetCurrentProcess().Id.ToString() })); + bool flag = exportProcess.DoExport(directoryName, text2, ifcexportOptions); + DateTime dateTime2 = DateTime.Now; + TimeSpan timeSpan = dateTime2 - dateTime; + dateTime = dateTime2; + string text3 = Path.Combine(directoryName, text2); + string text4 = text3 + ".ifc"; + if (File.Exists(text4 + ".log")) + { + File.Delete(text4 + ".log"); + } + if (File.Exists(text4)) + { + string text5 = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + text5 = text5.Substring(0, text5.LastIndexOf('.')); + STEPModel stepmodel = new STEPModel(text4); + stepmodel.Schema = EXPSchema.GetEXPSchema(stepmodel.SchemaVersion.First()); + ISTEPEntity istepentity = stepmodel.GetEntitiesByType("IFCORGANIZATION", true).FirstOrDefault(); + if (istepentity != null) + { + istepentity.Data.SetString(1, "SZ-IFC转换插件" + text5); + } + ISTEPEntity istepentity2 = stepmodel.GetEntitiesByType("IFCAPPLICATION", true).FirstOrDefault(); + if (istepentity2 != null) + { + istepentity2.Data.SetString(1, text5); + istepentity2.Data.SetString(2, "SZ-IFC转换插件"); + istepentity2.Data.SetString(3, ""); + } + try + { + TrimClassification.TrimClassificationInModel(stepmodel); + } + catch (Exception ex) + { + App_IFCExporter_StartUp.log.WriteException("Classification_Delete_ERR", ex); + } + stepmodel.Write(text4); + } + if (flag && App_IFCExporter_StartUp.DO_STAT) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "START_STAT"); + //Utils_SendMessage.UpdateProgressUI("Report"); + Dictionary dictionary = new Dictionary(); + if (text != null) + { + dictionary["RVT文件大小(MB)"] = text; + } + dictionary["RVT-IFC导出用时(秒)"] = timeSpan.TotalSeconds.ToString(); + IModel model = exportProcess.LoadExportedIFC(text4, ref dictionary); + if (new FilteredElementCollector(document).OfClass(typeof(Wire)).Count() > 0) + { + exportProcess.DoPostFix(document, model, text4); + } + exportProcess.DoStatistic(model, commonFileDialogCheckBox2.IsChecked, ref dictionary); + dateTime2 = DateTime.Now; + TimeSpan timeSpan2 = dateTime2 - dateTime; + dictionary["RVT-IFC统计用时(秒)"] = timeSpan2.TotalSeconds.ToString(); + XlsxReport.WriteReport(text3 + ".ifc.xlsx", dictionary, "-", text2, dateTime2.ToString(), true, commonFileDialogCheckBox2.IsChecked); + } + //Utils_SendMessage.ExitProgressBar(); + if (flag && commonFileDialogCheckBox.IsChecked) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "START_COMP"); + try + { + string[] array = new string[] + { + text4, + text4, + App_IFCExporter_StartUp.log.path + }; + //Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_COMPRESS_PATH, array); + } + catch (Exception ex2) + { + App_IFCExporter_StartUp.log.WriteException("COMPRESS_ERR", ex2); + } + } + if (flag && commonFileDialogCheckBox3.IsChecked) + { + GC.Collect(); + App_IFCExporter_StartUp.log.Write("EXPORT", "START_Texture"); + try + { + string text6 = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName().Replace(".", "")); + string text7 = text6 + ".obj"; + string text8 = text6 + ".mtl"; + string text9 = Path.Combine(Path.GetDirectoryName(text7), "textures"); + if (Command_ObjExport.ObjExport(document, text7, text9) == null) + { + App_IFCExporter_StartUp.log.Write("Texture", "OBJ Export Success."); + string[] array2 = new string[] + { + text7, + text4, + App_IFCExporter_StartUp.log.path + }; + //Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_TEXTURE_PATH, array2); + Thread.Sleep(500); + try + { + if (File.Exists(text7)) + { + File.Delete(text7); + } + if (File.Exists(text8)) + { + File.Delete(text8); + } + } + catch + { + } + } + } + catch (Exception ex3) + { + App_IFCExporter_StartUp.log.WriteException("TEXTURE_ERR", ex3); + + if (document.IsValidObject) + { + document.Close(false); + } + } + + } + if (document.IsValidObject) + { + document.Close(false); + } + App_IFCExporter_StartUp.log.Write("EXPORT", "END"); + } + MessageBox.Show("导出结束"); + + } + catch (Exception ex4) + { + App_IFCExporter_StartUp.log.WriteException("EXPORT", ex4); + } + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_IFCExport.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_IFCExport.cs new file mode 100644 index 0000000..15c793d --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_IFCExport.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Windows.Forms; + +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using Autodesk.Revit.UI; + +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser; + +using IFC_ExcelReport; + +using IFC_Revit_Interop.NetCore; +using IFC_Revit_Interop.Utils; + +using Microsoft.WindowsAPICodePack.Dialogs; +using Microsoft.WindowsAPICodePack.Dialogs.Controls; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000008 RID: 8 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_IFCExport : IExternalCommand + { + // Token: 0x1700000A RID: 10 + // (get) Token: 0x06000021 RID: 33 RVA: 0x0000385C File Offset: 0x00001A5C + public static string DefaultLicenseDir + { + get + { + string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cbims\\"); + if (!Directory.Exists(text)) + { + Directory.CreateDirectory(text); + } + return text; + } + } + + // Token: 0x06000022 RID: 34 RVA: 0x0000388A File Offset: 0x00001A8A + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + DoExport_WithForm(commandData.Application); + return 0; + } + internal static void DoExport_WithForm(UIApplication uiApp) + { + try + { + Document document = uiApp.ActiveUIDocument.Document; + CommonSaveFileDialog commonSaveFileDialog = new CommonSaveFileDialog + { + OverwritePrompt = true, + DefaultExtension = ".ifc", + Title = "导出IFC" + }; + commonSaveFileDialog.Filters.Add(new CommonFileDialogFilter("IFC4", "*.ifc")); + + string text = null; + if (!string.IsNullOrEmpty(document.PathName)) + { + commonSaveFileDialog.InitialDirectory = Path.GetDirectoryName(document.PathName); + commonSaveFileDialog.DefaultFileName = Path.GetFileNameWithoutExtension(document.PathName); + if (File.Exists(document.PathName)) + { + text = ((double)new FileInfo(document.PathName).Length / 1024.0 / 1024.0).ToString(); + } + } + CommonFileDialogCheckBox commonFileDialogCheckBox = new CommonFileDialogCheckBox("compress", "压缩IFC", true); + commonSaveFileDialog.Controls.Add(commonFileDialogCheckBox); + CommonFileDialogCheckBox commonFileDialogCheckBox2 = new CommonFileDialogCheckBox("report", "简化报告", true); + commonSaveFileDialog.Controls.Add(commonFileDialogCheckBox2); + CommonFileDialogCheckBox commonFileDialogCheckBox3 = new CommonFileDialogCheckBox("texture", "添加纹理", false); + commonSaveFileDialog.Controls.Add(commonFileDialogCheckBox3); + CommonFileDialogComboBox commonFileDialogComboBox = new CommonFileDialogComboBox(); + commonFileDialogComboBox.Items.Add(new CommonFileDialogComboBoxItem("原点: 场地测量点")); + commonFileDialogComboBox.Items.Add(new CommonFileDialogComboBoxItem("原点: 项目基点")); + commonFileDialogComboBox.SelectedIndex = 1; + commonSaveFileDialog.Controls.Add(commonFileDialogComboBox); + commonSaveFileDialog.EnsureValidNames = true; + commonSaveFileDialog.EnsurePathExists = true; + var result = commonSaveFileDialog.ShowDialog(); + if (result == CommonFileDialogResult.Cancel || result == CommonFileDialogResult.None) + { + return; + } + string fileName = Path.Combine(commonSaveFileDialog.InitialDirectory, commonSaveFileDialog.DefaultFileName); + string directoryName = Path.GetDirectoryName(fileName); + string text2 = Path.GetFileName(fileName); + if (text2.EndsWith(".ifc")) + { + text2 = text2.Substring(0, text2.Length - 4); + } + IFCExportOptions ifcexportOptions = new IFCExportOptions(); + ifcexportOptions.AddOption("ExportInternalRevitPropertySets", true.ToString()); + ifcexportOptions.AddOption("ExportIFCCommonPropertySets", true.ToString()); + ifcexportOptions.ExportBaseQuantities = true; + ifcexportOptions.AddOption("SitePlacement", (commonFileDialogComboBox.SelectedIndex + 1).ToString()); + ifcexportOptions.FileVersion = App_IFCExporter_StartUp.V_IFC4; + DateTime dateTime = DateTime.Now; + ExportProcess exportProcess = new ExportProcess(document); + //Utils_SendMessage.CreateProgressBar(Utils_Process.StartProcess(Settings_IFC.RUN_ProgressBar_PATH, new string[] { Process.GetCurrentProcess().Id.ToString() })); + bool flag = exportProcess.DoExport(directoryName, text2, ifcexportOptions); + DateTime dateTime2 = DateTime.Now; + TimeSpan timeSpan = dateTime2 - dateTime; + dateTime = dateTime2; + string text3 = Path.Combine(directoryName, text2); + string text4 = text3 + ".ifc"; + if (File.Exists(text4 + ".log")) + { + File.Delete(text4 + ".log"); + } + if (File.Exists(text4)) + { + string text5 = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + text5 = text5.Substring(0, text5.LastIndexOf('.')); + STEPModel stepmodel = new STEPModel(text4); + stepmodel.Schema = EXPSchema.GetEXPSchema(stepmodel.SchemaVersion.First()); + ISTEPEntity istepentity = stepmodel.GetEntitiesByType("IFCORGANIZATION", true).FirstOrDefault(); + if (istepentity != null) + { + istepentity.Data.SetString(1, "SZ-IFC转换插件" + text5); + } + ISTEPEntity istepentity2 = stepmodel.GetEntitiesByType("IFCAPPLICATION", true).FirstOrDefault(); + if (istepentity2 != null) + { + istepentity2.Data.SetString(1, text5); + istepentity2.Data.SetString(2, "SZ-IFC转换插件"); + istepentity2.Data.SetString(3, ""); + } + try + { + TrimClassification.TrimClassificationInModel(stepmodel); + } + catch (Exception ex) + { + App_IFCExporter_StartUp.log.WriteException("Classification_Delete_ERR", ex); + } + stepmodel.Write(text4); + } + if (flag && App_IFCExporter_StartUp.DO_STAT) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "START_STAT"); + Utils_SendMessage.UpdateProgressUI("Report"); + Dictionary dictionary = new Dictionary(); + if (text != null) + { + dictionary["RVT文件大小(MB)"] = text; + } + dictionary["RVT-IFC导出用时(秒)"] = timeSpan.TotalSeconds.ToString(); + IModel model = exportProcess.LoadExportedIFC(text4, ref dictionary); + if (new FilteredElementCollector(document).OfClass(typeof(Wire)).Count() > 0) + { + exportProcess.DoPostFix(document, model, text4); + } + exportProcess.DoStatistic(model, commonFileDialogCheckBox2.IsChecked, ref dictionary); + dateTime2 = DateTime.Now; + TimeSpan timeSpan2 = dateTime2 - dateTime; + dictionary["RVT-IFC统计用时(秒)"] = timeSpan2.TotalSeconds.ToString(); + XlsxReport.WriteReport(text3 + ".ifc.xlsx", dictionary, "-", text2, dateTime2.ToString(), true, commonFileDialogCheckBox2.IsChecked); + } + Utils_SendMessage.ExitProgressBar(); + if (flag && commonFileDialogCheckBox.IsChecked) + { + App_IFCExporter_StartUp.log.Write("EXPORT", "START_COMP"); + try + { + string[] array = new string[] + { + text4, + text4, + App_IFCExporter_StartUp.log.path + }; + Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_COMPRESS_PATH, array); + } + catch (Exception ex2) + { + App_IFCExporter_StartUp.log.WriteException("COMPRESS_ERR", ex2); + } + } + if (flag && commonFileDialogCheckBox3.IsChecked) + { + GC.Collect(); + App_IFCExporter_StartUp.log.Write("EXPORT", "START_Texture"); + try + { + string text6 = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName().Replace(".", "")); + string text7 = text6 + ".obj"; + string text8 = text6 + ".mtl"; + string text9 = Path.Combine(Path.GetDirectoryName(text7), "textures"); + if (Command_ObjExport.ObjExport(document, text7, text9) == null) + { + App_IFCExporter_StartUp.log.Write("Texture", "OBJ Export Success."); + string[] array2 = new string[] + { + text7, + text4, + App_IFCExporter_StartUp.log.path + }; + Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_TEXTURE_PATH, array2); + Thread.Sleep(500); + try + { + if (File.Exists(text7)) + { + File.Delete(text7); + } + if (File.Exists(text8)) + { + File.Delete(text8); + } + } + catch + { + } + } + } + catch (Exception ex3) + { + App_IFCExporter_StartUp.log.WriteException("TEXTURE_ERR", ex3); + document.Close(false); + } + document.Close(false); + } + App_IFCExporter_StartUp.log.Write("EXPORT", "END"); + + + } + catch (Exception ex4) + { + App_IFCExporter_StartUp.log.WriteException("EXPORT", ex4); + } + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_ObjExport.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_ObjExport.cs new file mode 100644 index 0000000..1b0f3c8 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_ObjExport.cs @@ -0,0 +1,128 @@ +using System; +using System.Diagnostics; +using System.IO; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using IFC_Revit_Interop.Utils; +using Microsoft.WindowsAPICodePack.Dialogs; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000009 RID: 9 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_ObjExport : IExternalCommand + { + // Token: 0x1700000B RID: 11 + // (get) Token: 0x06000024 RID: 36 RVA: 0x000038A0 File Offset: 0x00001AA0 + public static string DefaultLicenseDir + { + get + { + string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cbims\\"); + if (!Directory.Exists(text)) + { + Directory.CreateDirectory(text); + } + return text; + } + } + + // Token: 0x06000025 RID: 37 RVA: 0x000038D0 File Offset: 0x00001AD0 + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + Document document = commandData.Application.ActiveUIDocument.Document; + CommonSaveFileDialog commonSaveFileDialog = new CommonSaveFileDialog(); + commonSaveFileDialog.Title = "保存模型视图"; + if (!string.IsNullOrEmpty(document.PathName)) + { + commonSaveFileDialog.InitialDirectory = Path.GetDirectoryName(document.PathName); + commonSaveFileDialog.DefaultFileName = Path.GetFileNameWithoutExtension(document.PathName); + } + commonSaveFileDialog.Filters.Add(new CommonFileDialogFilter("OBJ", "*.obj")); + commonSaveFileDialog.EnsureValidNames = true; + commonSaveFileDialog.EnsurePathExists = true; + if (commonSaveFileDialog.ShowDialog() != CommonFileDialogResult.Ok) + { + return (Result)1; + } + string fileName = commonSaveFileDialog.FileName; + Command_ObjExport.ObjExport(document, fileName, fileName); + return 0; + } + + // Token: 0x06000026 RID: 38 RVA: 0x00003972 File Offset: 0x00001B72 + public static FilteredElementCollector GetAllInViewCollector(View view) + { + return new FilteredElementCollector(view.Document, view.Id).WhereElementIsNotElementType(); + } + + // Token: 0x06000027 RID: 39 RVA: 0x0000398C File Offset: 0x00001B8C + public static Result ObjExport(Document doc, string objResultPath, string texturePath) + { + if (doc == null) + { + return (Result) (- 1); + } + Utils_SendMessage.CreateProgressBar(Utils_Process.StartProcess(Settings_IFC.RUN_ProgressBar_PATH, new string[] { Process.GetCurrentProcess().Id.ToString() })); + Utils_SendMessage.UpdateProgressUI("ExportTexture"); + Utils_SendMessage.UpdateProgressUI("Init"); + View view = doc.ActiveView; + bool flag = false; + int num; + if (view != null && view.ViewType == (ViewType)4) + { + flag = true; + num = Command_ObjExport.GetAllInViewCollector(view).GetElementCount(); + } + else + { + int num2 = 0; + foreach (View view2 in Command_ViewExport.GetAllViews(doc, true)) + { + num = Command_ObjExport.GetAllInViewCollector(view2).GetElementCount(); + if (num > num2) + { + num2 = num; + view = view2; + flag = true; + } + } + num = num2; + } + if (!flag) + { + Utils_SendMessage.ExitProgressBar(); + return (Result)(-1); + } + Result result; + try + { + int num3 = 5; + using (CustomExporter customExporter = new CustomExporter(doc, new Rvt2Obj(doc, objResultPath, texturePath, num3, Command_ObjExport.log) + { + totalElementCount = num + })) + { + customExporter.IncludeGeometricObjects = false; + customExporter.ShouldStopOnError = true; + customExporter.Export(view as View3D); + } + Utils_SendMessage.UpdateProgressUI(0, 100, 1.0); + Utils_SendMessage.ExitProgressBar(); + result = 0; + } + catch (Exception ex) + { + Command_ObjExport.log.WriteException("TEXTURE_ERR_OBJ", ex); + Utils_SendMessage.ExitProgressBar(); + result = (Result)(-1); + } + return result; + } + + // Token: 0x0400001F RID: 31 + internal static Log log = new Log(Settings_IFC.LOG_PATH, true); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_Test_ParentFinder.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_Test_ParentFinder.cs new file mode 100644 index 0000000..5cf8f34 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_Test_ParentFinder.cs @@ -0,0 +1,29 @@ +using System; +using System.IO; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using IFC_Revit_Interop.Utils; +using Newtonsoft.Json; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200001E RID: 30 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_Test_ParentFinder : IExternalCommand + { + // Token: 0x0600008B RID: 139 RVA: 0x00007848 File Offset: 0x00005A48 + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + ParentFinder parentFinder = new ParentFinder(commandData.Application.ActiveUIDocument.Document, new Log(null, true)); + parentFinder.Find(); + using (StreamWriter streamWriter = new StreamWriter("d:/1.json")) + { + string text = JsonConvert.SerializeObject(parentFinder.ChildToParent); + streamWriter.Write(text); + } + return 0; + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_ViewExport.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_ViewExport.cs new file mode 100644 index 0000000..053eb94 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Command_ViewExport.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser; +using IFC_Revit_Interop.NetCore; +using IFC_Revit_Interop.Utils; +using Microsoft.WindowsAPICodePack.Dialogs; +using Newtonsoft.Json; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200000B RID: 11 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_ViewExport : IExternalCommand + { + // Token: 0x1700000C RID: 12 + // (get) Token: 0x06000044 RID: 68 RVA: 0x00004938 File Offset: 0x00002B38 + public static string DefaultLicenseDir + { + get + { + string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "cbims\\"); + if (!Directory.Exists(text)) + { + Directory.CreateDirectory(text); + } + return text; + } + } + + // Token: 0x06000045 RID: 69 RVA: 0x00004968 File Offset: 0x00002B68 + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + Document document = commandData.Application.ActiveUIDocument.Document; + CommonSaveFileDialog commonSaveFileDialog = new CommonSaveFileDialog(); + commonSaveFileDialog.Title = "保存模型视图"; + if (!string.IsNullOrEmpty(document.PathName)) + { + commonSaveFileDialog.InitialDirectory = Path.GetDirectoryName(document.PathName); + commonSaveFileDialog.DefaultFileName = Path.GetFileNameWithoutExtension(document.PathName); + } + commonSaveFileDialog.Filters.Add(new CommonFileDialogFilter("Json", "*.json")); + commonSaveFileDialog.EnsureValidNames = true; + commonSaveFileDialog.EnsurePathExists = true; + if (commonSaveFileDialog.ShowDialog() != CommonFileDialogResult.Ok) + { + return (Result)1; + } + string fileName = commonSaveFileDialog.FileName; + return Command_ViewExport.DoExportViewPack(document, Path.GetDirectoryName(fileName), Path.GetFileName(fileName), null, true); + } + + // Token: 0x06000046 RID: 70 RVA: 0x00004A14 File Offset: 0x00002C14 + internal static Result DoExportViewPack(Document document, string exportPath, string exportFileName, IfcExporterProcessMessage msg = null, bool addGridToView = true) + { + List allViews = Command_ViewExport.GetAllViews(document, true); + HashSet hashSet = new HashSet(); + if (msg != null) + { + if (msg.Arguments != null && msg.Arguments.ContainsKey("ViewNames")) + { + hashSet = new HashSet(JsonConvert.DeserializeObject>(msg.Arguments["ViewNames"])); + msg.Arguments["ViewCount"] = hashSet.Count.ToString(); + } + if (msg.Arguments == null) + { + msg.Arguments = new Dictionary(); + } + } + List list = new List(); + foreach (View view in allViews) + { + list.Add(new ViewData(view)); + } + try + { + string text = ""; + string text2 = Path.Combine(exportPath, exportFileName + ".ifc"); + string text3 = Path.Combine(exportPath, exportFileName + ".origin.ifc"); + if (File.Exists(text2)) + { + text = text2; + } + else if (File.Exists(text3)) + { + text = text3; + } + ISTEPModel istepmodel = null; + HashSet hashSet2 = null; + if (text.Length > 0) + { + istepmodel = new STEPModel(text); + istepmodel.Schema = EXPSchema.GetEXPSchema(istepmodel.SchemaVersion.First()); + hashSet2 = new HashSet(istepmodel.GetEntitiesByType("IfcProduct", true)); + } + int num = 0; + foreach (ViewData viewData in list) + { + if (msg == null || hashSet.Contains(viewData.ViewName)) + { + File.WriteAllText(Path.Combine(exportPath, exportFileName + "_View" + num.ToString() + ".json"), JsonConvert.SerializeObject(viewData)); + if (text.Length > 0) + { + List elements = viewData.Elements; + HashSet hashSet3 = new HashSet(); + using (List.Enumerator enumerator3 = elements.GetEnumerator()) + { + while (enumerator3.MoveNext()) + { + ElementData eleData = enumerator3.Current; + hashSet3.UnionWith(from e in hashSet2 + where e.Data.GetString(0) == eleData.IFCGUID + select e.Id); + hashSet3.UnionWith(from e in hashSet2 + where e.Data.Count >= 8 + where e.Data.GetString(7) == eleData.Id.ToString() + select e.Id); + } + } + if (addGridToView) + { + hashSet3.UnionWith(from e in hashSet2 + where e.Type.ToUpper() == "IFCGRID" + select e.Id); + } + string text4 = Path.Combine(exportPath, exportFileName + "_View" + num.ToString() + ".ifc"); + SubModelExtractor.MVDRootedExtractor(istepmodel, hashSet3.ToList(), text4); + } + num++; + } + } + } + catch (Exception ex) + { + Command_ViewExport.log.Write("EXPORT VIEW", "Error: " + ex.Message); + return (Result)(-1); + } + Command_ViewExport.log.Write("EXPORT VIEW", "SUCCESS"); + return 0; + } + + // Token: 0x06000047 RID: 71 RVA: 0x00004E00 File Offset: 0x00003000 + public static List GetAllViews(Document doc, bool onlyThreeDType = true) + { + FilteredElementCollector filteredElementCollector = new FilteredElementCollector(doc); + filteredElementCollector.OfClass(typeof(View)); + IEnumerable enumerable = from Element f in filteredElementCollector + where (f as View).CanBePrinted + select f as View; + List list = new List(); + foreach (View view in enumerable) + { + if (!(view.Id == null) && view.Id.IntegerValue >= 0 && (!onlyThreeDType || view.ViewType == (ViewType)4)) + { + list.Add(view); + } + } + return list; + } + + // Token: 0x06000048 RID: 72 RVA: 0x00004EDC File Offset: 0x000030DC + public static FilteredElementCollector GetAllInViewCollector(View view) + { + return new FilteredElementCollector(view.Document, view.Id).WhereElementIsNotElementType().WhereElementIsViewIndependent(); + } + + // Token: 0x04000039 RID: 57 + internal static Log log = new Log(Settings_IFC.LOG_PATH, true); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/CommonTaskStatus.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/CommonTaskStatus.cs new file mode 100644 index 0000000..302c6ff --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/CommonTaskStatus.cs @@ -0,0 +1,15 @@ +using System; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000012 RID: 18 + public enum CommonTaskStatus + { + // Token: 0x04000066 RID: 102 + None, + // Token: 0x04000067 RID: 103 + Success, + // Token: 0x04000068 RID: 104 + Fail + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/CurtainParentFinder.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/CurtainParentFinder.cs new file mode 100644 index 0000000..e123683 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/CurtainParentFinder.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.IFC; +using Autodesk.Revit.Exceptions; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000019 RID: 25 + internal class CurtainParentFinder + { + // Token: 0x0600007A RID: 122 RVA: 0x00006EAB File Offset: 0x000050AB + public CurtainParentFinder(ParentFinder host) + { + this.host = host; + this.doc = host.doc; + } + + // Token: 0x0600007B RID: 123 RVA: 0x00006EC8 File Offset: 0x000050C8 + public void Find() + { + foreach (Element element2 in this.host.coll.Where((Element element) => element is Wall || element is FootPrintRoof || element is ExtrusionRoof || element is CurtainSystem)) + { + try + { + ICollection curtainChildren = this.GetCurtainChildren(element2); + if (curtainChildren != null) + { + foreach (ElementId elementId in curtainChildren) + { + this.host.ChildToParent[elementId.IntegerValue] = element2.Id.IntegerValue; + } + } + } + catch (Exception ex) + { + this.host.log.WriteException("ERR_CurtainParentFinder", ex); + } + } + } + + // Token: 0x0600007C RID: 124 RVA: 0x00006FC0 File Offset: 0x000051C0 + private ICollection GetCurtainChildren(Element hostElement) + { + CurtainGridSet curtainGridSet = this.GetCurtainGridSet(hostElement); + if (curtainGridSet == null && hostElement is Wall) + { + return ExporterIFCUtils.GetLegacyCurtainSubElements(hostElement); + } + if (curtainGridSet.Size == 0) + { + return null; + } + return this.GetSubElements(curtainGridSet); + } + + // Token: 0x0600007D RID: 125 RVA: 0x00006FF8 File Offset: 0x000051F8 + private CurtainGridSet GetCurtainGridSet(Element element) + { + CurtainGridSet curtainGridSet = null; + if (element is Wall) + { + Wall wall = element as Wall; + if (!this.IsLegacyCurtainWall(wall)) + { + CurtainGrid curtainGrid = wall.CurtainGrid; + curtainGridSet = new CurtainGridSet(); + if (curtainGrid != null) + { + curtainGridSet.Insert(curtainGrid); + } + } + } + else if (element is FootPrintRoof) + { + curtainGridSet = (element as FootPrintRoof).CurtainGrids; + } + else if (element is ExtrusionRoof) + { + curtainGridSet = (element as ExtrusionRoof).CurtainGrids; + } + else if (element is CurtainSystem) + { + curtainGridSet = (element as CurtainSystem).CurtainGrids; + } + return curtainGridSet; + } + + // Token: 0x0600007E RID: 126 RVA: 0x0000707C File Offset: 0x0000527C + private ICollection GetSubElements(CurtainGridSet gridSet) + { + HashSet hashSet = new HashSet(); + foreach (object obj in gridSet) + { + CurtainGrid curtainGrid = (CurtainGrid)obj; + hashSet.UnionWith(this.GetVisiblePanelsForGrid(curtainGrid)); + hashSet.UnionWith(curtainGrid.GetMullionIds()); + } + return hashSet; + } + + // Token: 0x0600007F RID: 127 RVA: 0x000070EC File Offset: 0x000052EC + private ICollection GetVisiblePanelsForGrid(CurtainGrid curtainGrid) + { + ICollection panelIds = curtainGrid.GetPanelIds(); + if (panelIds == null) + { + return null; + } + HashSet hashSet = new HashSet(); + foreach (ElementId elementId in panelIds) + { + Element element = this.doc.GetElement(elementId); + if (element != null) + { + ElementId elementId2 = ElementId.InvalidElementId; + if (element is Panel) + { + elementId2 = (element as Panel).FindHostPanel(); + } + if (elementId2 != ElementId.InvalidElementId) + { + Element element2 = this.doc.GetElement(elementId2); + if (this._isCurtainSystem(element2)) + { + CurtainGridSet curtainGridSet = this.GetCurtainGridSet(element2); + if (curtainGridSet == null || curtainGridSet.Size == 0) + { + hashSet.Add(elementId2); + } + else + { + ICollection subElements = this.GetSubElements(curtainGridSet); + hashSet.UnionWith(subElements); + } + } + else + { + hashSet.Add(elementId2); + } + } + else + { + hashSet.Add(elementId); + } + } + } + return hashSet; + } + + // Token: 0x06000080 RID: 128 RVA: 0x000071EC File Offset: 0x000053EC + private bool _isCurtainSystem(Element element) + { + if (element == null) + { + return false; + } + CurtainGridSet curtainGridSet = this.GetCurtainGridSet(element); + if (curtainGridSet == null) + { + return element is Wall; + } + return curtainGridSet.Size > 0; + } + + // Token: 0x06000081 RID: 129 RVA: 0x0000721C File Offset: 0x0000541C + private bool IsLegacyCurtainWall(Wall wall) + { + try + { + CurtainGrid curtainGrid = wall.CurtainGrid; + if (curtainGrid == null) + { + return false; + } + curtainGrid.GetPanelIds(); + } + catch (Autodesk.Revit.Exceptions.InvalidOperationException ex) + { + if (ex.Message == "The host object is obsolete.") + { + return true; + } + throw ex; + } + return false; + } + + // Token: 0x0400007C RID: 124 + private ParentFinder host; + + // Token: 0x0400007D RID: 125 + private Document doc; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ElementData.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ElementData.cs new file mode 100644 index 0000000..b039338 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ElementData.cs @@ -0,0 +1,33 @@ +using System; +using Autodesk.Revit.DB; +using IFC_Revit_Interop.Utils; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200000D RID: 13 + public class ElementData + { + // Token: 0x0600004F RID: 79 RVA: 0x00005638 File Offset: 0x00003838 + public ElementData() + { + } + + // Token: 0x06000050 RID: 80 RVA: 0x00005640 File Offset: 0x00003840 + public ElementData(Element e, ViewData view = null) + { + this.Id = e.Id.IntegerValue; + Category category = e.Category; + this.Category = ((category != null) ? category.Name : null); + this.IFCGUID = e.IfcGUID(); + } + + // Token: 0x04000046 RID: 70 + public int Id; + + // Token: 0x04000047 RID: 71 + public string Category; + + // Token: 0x04000048 RID: 72 + public string IFCGUID; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ExportProcess.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ExportProcess.cs new file mode 100644 index 0000000..a96bd08 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ExportProcess.cs @@ -0,0 +1,345 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Architecture; +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser; +using CBIMS.STEParser.EB; +using CBIMS.STEParser.EB.IFC2X3; +using CBIMS.STEParser.EB.IFC4; +using IFC_ExcelReport; +using IFC_Revit_Interop.NetCore; +using IFC_Revit_Interop.NetCore.PostFix; +using IFC_Revit_Interop.Utils; +using Revit.IFC.CBMod.Export.Exporter; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200000E RID: 14 + public class ExportProcess + { + // Token: 0x06000051 RID: 81 RVA: 0x0000567D File Offset: 0x0000387D + internal ExportProcess(Document doc) + { + this.doc = doc; + } + + // Token: 0x06000052 RID: 82 RVA: 0x00005698 File Offset: 0x00003898 + internal void CreateNewDocFromRFA(out List extractToSubModel) + { + extractToSubModel = new List(); + string pathName = this.doc.PathName; + this.doc = this.doc.Application.NewProjectDocument(0); + Transaction transaction = new Transaction(this.doc, "RFA Loader"); + transaction.Start(); + Family family = null; + this.doc.LoadFamily(pathName, out family); + ElementId elementId = family.GetFamilySymbolIds().First(); + FamilySymbol familySymbol = this.doc.GetElement(elementId) as FamilySymbol; + if (!familySymbol.IsActive) + { + familySymbol.Activate(); + } + XYZ xyz = new XYZ(-1.0, 1.0, -1.0); + ViewFamilyType viewFamilyType = new FilteredElementCollector(this.doc).OfClass(typeof(ViewFamilyType)).Cast().FirstOrDefault((ViewFamilyType x) => x.ViewFamily == (ViewFamily)102); + View3D.CreateIsometric(this.doc, viewFamilyType.Id).SetOrientation(new ViewOrientation3D(xyz, new XYZ(0.0, 1.0, 1.0), new XYZ(0.0, 1.0, -1.0))); + if (familySymbol.Family.get_Parameter((BuiltInParameter)(-1012843)).AsInteger() == 1) + { + Line line = Line.CreateBound(XYZ.Zero, new XYZ(10.0, 0.0, 0.0)); + Wall wall = Wall.Create(this.doc, line, ExportProcess.FindAndSortLevels(this.doc).Last().Id, false); + Level level = this.doc.GetElement(wall.LevelId) as Level; + FamilyInstance familyInstance = ExportProcess.InsertDoorOrWindow(familySymbol, wall, level, -1.0, -1.0); + extractToSubModel.Add(familyInstance.Id.IntegerValue); + } + else + { + Level level2 = Level.Create(this.doc, 10.0); + this.doc.Create.NewFamilyInstance(new XYZ(0.0, 0.0, 0.0), familySymbol, level2, 0); + } + transaction.Commit(); + SaveAsOptions saveAsOptions = new SaveAsOptions(); + saveAsOptions.OverwriteExistingFile = true; + this.doc.SaveAs(pathName.Substring(0, pathName.Length - 4) + ".rvt", saveAsOptions); + } + + // Token: 0x06000053 RID: 83 RVA: 0x00005928 File Offset: 0x00003B28 + private static FamilyInstance InsertDoorOrWindow(FamilySymbol symbol, Wall wall, Level level, double centerToLeft = -1.0, double bottomToBottom = -1.0) + { + LocationCurve locationCurve = wall.Location as LocationCurve; + XYZ endPoint = locationCurve.Curve.GetEndPoint(0); + XYZ endPoint2 = locationCurve.Curve.GetEndPoint(1); + XYZ xyz = (endPoint + endPoint2) / 2.0; + if (centerToLeft >= 0.0) + { + xyz = endPoint + (endPoint2 - endPoint).Normalize() * centerToLeft; + } + FamilyInstance familyInstance = wall.Document.Create.NewFamilyInstance(xyz, symbol, wall, level, 0); + double num = familyInstance.get_Parameter((BuiltInParameter)(-1001362)).AsDouble(); + double num2 = familyInstance.get_Parameter((BuiltInParameter) (- 1001361)).AsDouble(); + double num3 = wall.get_Parameter((BuiltInParameter) (- 1001105)).AsDouble() / 2.0 - (num - num2) / 2.0; + if (bottomToBottom >= 0.0) + { + num3 = bottomToBottom; + } + familyInstance.get_Parameter((BuiltInParameter)(-1001361)).Set(num3); + return familyInstance; + } + + // Token: 0x06000054 RID: 84 RVA: 0x00005A1C File Offset: 0x00003C1C + public static IOrderedEnumerable FindAndSortLevels(Document doc) + { + return from Level e in new FilteredElementCollector(doc).WherePasses(new ElementClassFilter(typeof(Level), false)) + orderby e.Elevation + select e; + } + + // Token: 0x06000055 RID: 85 RVA: 0x00005A70 File Offset: 0x00003C70 + internal bool DoExport(string exportPath, string exportFileName, IFCExportOptions exportOptions) + { + Exporter.CBIMS_IFC_ActivateOnce = true; + this.log.Write("EXPORT", "START"); + bool flag; + try + { + List list = null; + if (this.doc.PathName.EndsWith(".rfa")) + { + this.CreateNewDocFromRFA(out list); + } + Transaction transaction = new Transaction(this.doc, "My Export IFC"); + transaction.Start(); + if (this.doc.Export(exportPath, exportFileName, exportOptions)) + { + if (list != null && list.Count > 0) + { + string text = Path.Combine(exportPath, exportFileName); + if (!text.EndsWith(".ifc")) + { + text += ".ifc"; + } + ISTEPModel istepmodel = new STEPModel(text); + istepmodel.Schema = EXPSchema.GetEXPSchema(istepmodel.SchemaVersion.First()); + HashSet hashSet = new HashSet(istepmodel.GetEntitiesByType("IfcElement", true)); + List list2 = new List(); + using (List.Enumerator enumerator = list.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + int insId = enumerator.Current; + list2.AddRange(from e in hashSet + where e.Data.GetString(7) == insId.ToString() + select e.Id); + } + } + SubModelExtractor.MVDRootedExtractor(istepmodel, list2, text); + } + this.log.Write("EXPORT", "SUCCESS " + exportPath + " " + exportFileName); + transaction.Commit(); + flag = true; + } + else + { + this.log.Write("EXPORT", "FAIL " + exportPath + " " + exportFileName); + transaction.RollBack(); + flag = false; + } + } + catch (Exception ex) + { + this.log.WriteException("EXPORT", ex); + flag = false; + } + return flag; + } + + // Token: 0x06000056 RID: 86 RVA: 0x00005C78 File Offset: 0x00003E78 + public static IEnumerable GetElementsForStatistics(Document doc) + { + HashSet hashSet = new FilteredElementCollector(doc).WhereElementIsNotElementType().WhereElementIsViewIndependent().ToHashSet(); + HashSet elementsToIgnore = new HashSet(); + HashSet hashSet2 = new HashSet(); + foreach (Element element in hashSet) + { + FamilyInstance familyInstance = element as FamilyInstance; + if (familyInstance == null || !familyInstance.Invisible) + { + Railing railing = element as Railing; + if (railing != null) + { + ICollection collection = RailingParentFinder.CollectSubElements(railing); + elementsToIgnore.UnionWith(collection); + hashSet2.Add(element); + } + else + { + Wall wall = element as Wall; + if (wall != null) + { + ElementId stackedWallOwnerId = wall.StackedWallOwnerId; + if (stackedWallOwnerId != ElementId.InvalidElementId) + { + Element element2 = doc.GetElement(stackedWallOwnerId); + if (element2 != null && element2 is Wall && (element2 as Wall).CurtainGrid != null) + { + continue; + } + } + hashSet2.Add(element); + } + else if (!(element is Opening) && !(element is Grid)) + { + hashSet2.Add(element); + } + } + } + } + return hashSet2.Where((Element x) => !elementsToIgnore.Contains(x.Id)).ToHashSet(); + } + + // Token: 0x06000057 RID: 87 RVA: 0x00005DB8 File Offset: 0x00003FB8 + internal IModel LoadExportedIFC(string ifcFilePath, ref Dictionary rec) + { + if (File.Exists(ifcFilePath)) + { + return ModelLoader.Load(new STEPModel(ifcFilePath)); + } + throw new InvalidDataException(); + } + + // Token: 0x06000058 RID: 88 RVA: 0x00005DD4 File Offset: 0x00003FD4 + internal void DoPostFix(Document doc, IModel imodel, string path) + { + this.log.Write("EXPORT", "DO_POSTFIX"); + PostFixBase postFixBase; + if (imodel.SchemaVersion == IfcSchemaVersion.IFC2X3) + { + postFixBase = new PostFix_IFC2x3(doc, imodel as CBIMS.STEParser.EB.IFC2X3.Model, path); + } + else + { + if (imodel.SchemaVersion != IfcSchemaVersion.IFC4) + { + throw new NotSupportedException(); + } + postFixBase = new PostFix_IFC4(doc, imodel as CBIMS.STEParser.EB.IFC4.Model, path); + } + postFixBase.AddWires(); + postFixBase.Save(); + } + + // Token: 0x06000059 RID: 89 RVA: 0x00005E3C File Offset: 0x0000403C + internal void DoStatistic(IModel imodel, bool simplifyReport, ref Dictionary rec) + { + try + { + IEnumerable elementsForStatistics = ExportProcess.GetElementsForStatistics(this.doc); + AbstractReportGenerator abstractReportGenerator = new RevitReportGenerator(this.getCatMapFromRevit(elementsForStatistics)); + int num; + Dictionary> revitCodeMap = ExportProcess.getRevitCodeMap(this.doc, elementsForStatistics, ExportProcess.SKIPPING_NO_CODE_ELEMS, simplifyReport, out num); + Dictionary dictionary; + Dictionary idMapFromRevit = this.getIdMapFromRevit(elementsForStatistics, out dictionary); + abstractReportGenerator.Generate(imodel, idMapFromRevit, revitCodeMap, ref rec); + } + catch (Exception ex) + { + this.log.WriteException("STAT_ERR", ex); + } + } + + // Token: 0x0600005A RID: 90 RVA: 0x00005EB4 File Offset: 0x000040B4 + private Dictionary getCatMapFromRevit(IEnumerable elems) + { + Dictionary dictionary = new Dictionary(); + foreach (Element element in elems) + { + if (element != null && element.Category != null) + { + dictionary[element.Id.IntegerValue.ToString()] = element.Category.Name; + } + } + return dictionary; + } + + // Token: 0x0600005B RID: 91 RVA: 0x00005F2C File Offset: 0x0000412C + private Dictionary getIdMapFromRevit(IEnumerable elems, out Dictionary outInv) + { + Dictionary dictionary = new Dictionary(); + outInv = new Dictionary(); + foreach (Element element in elems) + { + dictionary[element.IfcGUID()] = element.Id.IntegerValue.ToString(); + outInv[element.Id.IntegerValue.ToString()] = element.IfcGUID(); + } + return dictionary; + } + + // Token: 0x0600005C RID: 92 RVA: 0x00005FBC File Offset: 0x000041BC + private static Dictionary> getRevitCodeMap(Document doc, IEnumerable elems, bool skippingNoCodeElems, bool simplifyReport, out int total) + { + Dictionary> dictionary = new Dictionary>(); + HashSet elemsWithVisibleGeom = Utils_Selection.GetElemsWithVisibleGeom(elems, Exporter.IFC_FilterView); + HashSet hashSet = new HashSet(); + foreach (Element element in elemsWithVisibleGeom) + { + hashSet.Add(element.Id.IntegerValue); + } + HashSet hashSet2 = new HashSet(); + total = 0; + foreach (Element element2 in elems) + { + string text = ExportProcess.CODE_PROP_NAME_INSTANCE; + if (element2 is SpatialElement) + { + text = ExportProcess.CODE_PROP_NAME_SPACE; + } + string text2; + if (Utils_Statistic.HasProp(doc, element2, text, out text2)) + { + if (!dictionary.ContainsKey(text2)) + { + dictionary.Add(text2, new HashSet()); + } + if (!simplifyReport || hashSet.Contains(element2.Id.IntegerValue)) + { + dictionary[text2].Add(element2.IfcGUID()); + } + } + else + { + if (skippingNoCodeElems || !hashSet.Contains(element2.Id.IntegerValue)) + { + continue; + } + hashSet2.Add(element2.IfcGUID()); + } + total++; + } + if (hashSet2.Count > 0) + { + dictionary["NULL"] = hashSet2; + } + return dictionary; + } + + // Token: 0x04000049 RID: 73 + private Log log = App_IFCExporter_StartUp.log; + + // Token: 0x0400004A RID: 74 + public static bool USE_MVDLITE = true; + + // Token: 0x0400004B RID: 75 + private static string CODE_PROP_NAME_INSTANCE = "深圳构件标识"; + + // Token: 0x0400004C RID: 76 + private static string CODE_PROP_NAME_SPACE = "深圳空间标识"; + + // Token: 0x0400004D RID: 77 + private static bool SKIPPING_NO_CODE_ELEMS = true; + + // Token: 0x0400004E RID: 78 + public Document doc; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ExternalEventHandler_Export.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ExternalEventHandler_Export.cs new file mode 100644 index 0000000..a59c675 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ExternalEventHandler_Export.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Pipes; +using System.Linq; +using System.Text; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using Autodesk.Revit.UI; +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser; +using CBIMS.STEParser.Translate; +using IFC_ExcelReport; +using IFC_Revit_Interop.Utils; +using Newtonsoft.Json; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200000F RID: 15 + public class ExternalEventHandler_Export : IExternalEventHandler + { + // Token: 0x0600005E RID: 94 RVA: 0x00006142 File Offset: 0x00004342 + public ExternalEventHandler_Export(Document doc, NamedPipeClientStream pipe, string exportDir, string exportFileName, IFCExportOptions exportOptions, IfcExporterProcessMessage passedInMsg) + { + this.doc = doc; + this.pipe = pipe; + this.exportDir = exportDir; + this.exportFileName = exportFileName; + this.exportOptions = exportOptions; + this.passedInMsg = passedInMsg; + } + + // Token: 0x0600005F RID: 95 RVA: 0x00006184 File Offset: 0x00004384 + public void Execute(UIApplication app) + { + try + { + Document document = app.ActiveUIDocument.Document; + IfcExporterProcessMessage ifcExporterProcessMessage = new IfcExporterProcessMessage(); + ifcExporterProcessMessage.Status = IfcExporterProgcessStatus.START; + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Success; + ifcExporterProcessMessage.Arguments = null; + using (BinaryWriter binaryWriter = new BinaryWriter(this.pipe, Encoding.UTF8, true)) + { + binaryWriter.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + ifcExporterProcessMessage.Status = IfcExporterProgcessStatus.END; + try + { + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.exportFileName); + string text = fileNameWithoutExtension + ".ifc"; + string text2 = fileNameWithoutExtension + ".origin.ifc"; + string text3 = text; + if (ExternalEventHandler_Export.DO_COMPRESS) + { + text3 = text2; + } + string text4 = Path.Combine(this.exportDir, text); + string text5 = Path.Combine(this.exportDir, text3); + DateTime dateTime = DateTime.Now; + this.log.Write("APP", "START_EXPORT " + text5); + string text6 = null; + if (!string.IsNullOrEmpty(this.doc.PathName) && File.Exists(this.doc.PathName)) + { + text6 = (new FileInfo(this.doc.PathName).Length / 1024L / 1024L).ToString(); + } + ExportProcess exportProcess = new ExportProcess(this.doc); + bool flag = exportProcess.DoExport(this.exportDir, text3, this.exportOptions); + DateTime dateTime2 = DateTime.Now; + TimeSpan timeSpan = dateTime2 - dateTime; + dateTime = dateTime2; + if (flag && this.passedInMsg.Arguments != null && this.passedInMsg.Arguments["translatePsetsQsets"].ToString().ToLower() == "true") + { + STEPModel stepmodel = new STEPModel(text5); + IFCPsetQsetToChinses.ProcessModel(stepmodel); + ((ISTEPModel)stepmodel).Write(text5); + } + if (flag && App_IFCExporter_StartUp.EXPORT_VIEWPACK) + { + if (this.passedInMsg.Arguments != null && this.passedInMsg.Arguments.ContainsKey("ViewNames")) + { + ifcExporterProcessMessage.Arguments = new Dictionary(); + ifcExporterProcessMessage.Arguments["ViewNames"] = this.passedInMsg.Arguments["ViewNames"]; + } + Command_ViewExport.DoExportViewPack(exportProcess.doc, this.exportDir, fileNameWithoutExtension, ifcExporterProcessMessage, true); + } + TimeSpan timeSpan2 = TimeSpan.Zero; + if (flag && ExternalEventHandler_Export.DO_COMPRESS) + { + try + { + this.log.Write("APP", "START_COMPRESS " + text4); + string[] array = new string[] + { + text5, + text4, + this.log.path + }; + Utils_Process.StartProcessAndWaitForExit(Settings_IFC.RUN_COMPRESS_PATH, array); + dateTime2 = DateTime.Now; + timeSpan2 = dateTime2 - dateTime; + } + catch (Exception ex) + { + this.log.WriteException("COMPRESS_ERR", ex); + text4 = text5; + } + dateTime = DateTime.Now; + } + this.log.Write("APP", "START_STAT"); + if (flag && ExternalEventHandler_Export.DO_STAT) + { + Dictionary dictionary = new Dictionary(); + dictionary["RVT-IFC导出用时(秒)"] = timeSpan.TotalSeconds.ToString(); + if (timeSpan2 != TimeSpan.Zero) + { + dictionary["RVT-IFC压缩用时(秒)"] = timeSpan2.TotalSeconds.ToString(); + } + if (text6 != null) + { + dictionary["RVT文件大小(MB)"] = text6; + } + IModel model = exportProcess.LoadExportedIFC(text4, ref dictionary); + if (new FilteredElementCollector(this.doc).OfClass(typeof(Wire)).Count() > 0) + { + exportProcess.DoPostFix(document, model, text4); + } + exportProcess.DoStatistic(model, false, ref dictionary); + dateTime2 = DateTime.Now; + TimeSpan timeSpan3 = dateTime2 - dateTime; + string text7 = Path.Combine(this.exportDir, fileNameWithoutExtension); + dictionary["RVT-IFC统计用时(秒)"] = timeSpan3.TotalSeconds.ToString(); + XlsxReport.WriteReport(text7 + ".ifc.xlsx", dictionary, "-", text7, dateTime2.ToString(), true, false); + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Success; + if (ifcExporterProcessMessage.Arguments == null) + { + ifcExporterProcessMessage.Arguments = dictionary; + } + else + { + ifcExporterProcessMessage.Arguments.Union(dictionary); + } + } + else + { + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Fail; + } + this.log.Write("APP", "ENDED"); + using (BinaryWriter binaryWriter2 = new BinaryWriter(this.pipe, Encoding.UTF8, true)) + { + binaryWriter2.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + } + catch (Exception ex2) + { + this.log.WriteException("EVENT_ERR", ex2); + ifcExporterProcessMessage.TaskStatus = CommonTaskStatus.Fail; + ifcExporterProcessMessage.Arguments = new Dictionary(); + ifcExporterProcessMessage.Arguments.Add("exception", "EVENT_ERR " + ex2.GetType().FullName + " " + ex2.Message); + using (BinaryWriter binaryWriter3 = new BinaryWriter(this.pipe, Encoding.UTF8, true)) + { + binaryWriter3.Write(JsonConvert.SerializeObject(ifcExporterProcessMessage)); + } + } + } + } + catch (Exception ex3) + { + this.log.WriteException("BAD_PIPE", ex3); + } + } + + // Token: 0x06000060 RID: 96 RVA: 0x00006720 File Offset: 0x00004920 + public string GetName() + { + return "IFC_Revit_Interop_Export"; + } + + // Token: 0x0400004F RID: 79 + private Log log = App_IFCExporter_StartUp.log; + + // Token: 0x04000050 RID: 80 + private Document doc; + + // Token: 0x04000051 RID: 81 + private string exportDir; + + // Token: 0x04000052 RID: 82 + private string exportFileName; + + // Token: 0x04000053 RID: 83 + private IFCExportOptions exportOptions; + + // Token: 0x04000054 RID: 84 + private IfcExporterProcessMessage passedInMsg; + + // Token: 0x04000055 RID: 85 + public static bool DO_STAT = Settings_IFC.DO_STAT == "true"; + + // Token: 0x04000056 RID: 86 + public static bool DO_COMPRESS = Settings_IFC.DO_COMPRESS == "true"; + + // Token: 0x04000057 RID: 87 + private NamedPipeClientStream pipe; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FIParentFinder.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FIParentFinder.cs new file mode 100644 index 0000000..2a52a43 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FIParentFinder.cs @@ -0,0 +1,36 @@ +using System; +using System.Linq; +using Autodesk.Revit.DB; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200001B RID: 27 + internal class FIParentFinder + { + // Token: 0x06000085 RID: 133 RVA: 0x00007528 File Offset: 0x00005728 + public FIParentFinder(ParentFinder host) + { + this.host = host; + } + + // Token: 0x06000086 RID: 134 RVA: 0x00007538 File Offset: 0x00005738 + public void Find() + { + foreach (Element element2 in this.host.coll.Where((Element element) => element is FamilyInstance && (element as FamilyInstance).SuperComponent != null)) + { + try + { + FamilyInstance familyInstance = element2 as FamilyInstance; + this.host.ChildToParent[familyInstance.Id.IntegerValue] = familyInstance.SuperComponent.Id.IntegerValue; + } + catch (Exception ex) + { + this.host.log.WriteException("ERR_FIParentFinder", ex); + } + } + } + + // Token: 0x0400007F RID: 127 + private ParentFinder host; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FileLinkInfo.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FileLinkInfo.cs new file mode 100644 index 0000000..b943668 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FileLinkInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000016 RID: 22 + internal class FileLinkInfo + { + // Token: 0x04000074 RID: 116 + public string fileName; + + // Token: 0x04000075 RID: 117 + public List linkInstances; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FormExportCountdown.Designer.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FormExportCountdown.Designer.cs new file mode 100644 index 0000000..677c5e5 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FormExportCountdown.Designer.cs @@ -0,0 +1,77 @@ +namespace IFC_Revit_Interop +{ + // Token: 0x02000010 RID: 16 + public partial class FormExportCountdown : global::System.Windows.Forms.Form + { + // Token: 0x06000069 RID: 105 RVA: 0x00006846 File Offset: 0x00004A46 + protected override void Dispose(bool disposing) + { + if (disposing && this.components != null) + { + this.components.Dispose(); + } + base.Dispose(disposing); + } + + // Token: 0x0600006A RID: 106 RVA: 0x00006868 File Offset: 0x00004A68 + private void InitializeComponent() + { + this.components = new global::System.ComponentModel.Container(); + this.label1 = new global::System.Windows.Forms.Label(); + this.buttonNow = new global::System.Windows.Forms.Button(); + this.buttonCancel = new global::System.Windows.Forms.Button(); + this.timer1 = new global::System.Windows.Forms.Timer(this.components); + base.SuspendLayout(); + this.label1.AutoSize = true; + this.label1.Location = new global::System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new global::System.Drawing.Size(101, 12); + this.label1.TabIndex = 0; + this.label1.Text = "秒后开始导出任务"; + this.buttonNow.Location = new global::System.Drawing.Point(32, 44); + this.buttonNow.Name = "buttonNow"; + this.buttonNow.Size = new global::System.Drawing.Size(75, 23); + this.buttonNow.TabIndex = 1; + this.buttonNow.Text = "立刻"; + this.buttonNow.UseVisualStyleBackColor = true; + this.buttonNow.Click += new global::System.EventHandler(this.buttonNow_Click); + this.buttonCancel.Location = new global::System.Drawing.Point(193, 44); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new global::System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "取消"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new global::System.EventHandler(this.buttonCancel_Click); + this.timer1.Interval = 1000; + this.timer1.Tick += new global::System.EventHandler(this.timer1_Tick); + base.AutoScaleDimensions = new global::System.Drawing.SizeF(6f, 12f); + base.AutoScaleMode = global::System.Windows.Forms.AutoScaleMode.Font; + base.ClientSize = new global::System.Drawing.Size(311, 79); + base.Controls.Add(this.buttonCancel); + base.Controls.Add(this.buttonNow); + base.Controls.Add(this.label1); + base.FormBorderStyle = global::System.Windows.Forms.FormBorderStyle.FixedDialog; + base.MaximizeBox = false; + base.MinimizeBox = false; + base.Name = "FormExportCountdown"; + this.Text = "导出倒计时"; + base.ResumeLayout(false); + base.PerformLayout(); + } + + // Token: 0x0400005B RID: 91 + private global::System.ComponentModel.IContainer components; + + // Token: 0x0400005C RID: 92 + private global::System.Windows.Forms.Label label1; + + // Token: 0x0400005D RID: 93 + private global::System.Windows.Forms.Button buttonNow; + + // Token: 0x0400005E RID: 94 + private global::System.Windows.Forms.Button buttonCancel; + + // Token: 0x0400005F RID: 95 + private global::System.Windows.Forms.Timer timer1; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FormExportCountdown.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FormExportCountdown.cs new file mode 100644 index 0000000..7bd4700 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/FormExportCountdown.cs @@ -0,0 +1,77 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using Autodesk.Revit.UI; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000010 RID: 16 + public partial class FormExportCountdown : Form + { + // Token: 0x06000062 RID: 98 RVA: 0x00006754 File Offset: 0x00004954 + public FormExportCountdown(ExternalEventHandler_Export handler, ExternalEvent exevent) + { + this.handler = handler; + this.exevent = exevent; + this.InitializeComponent(); + this.COUNTDOWN = int.Parse(Settings_IFC.EXPORT_COUNTDOWN); + this.label1.Text = this.COUNTDOWN.ToString() + " 秒后开始导出"; + } + + // Token: 0x06000063 RID: 99 RVA: 0x000067AB File Offset: 0x000049AB + internal void StartCountdown() + { + this.timer1.Start(); + } + + // Token: 0x06000064 RID: 100 RVA: 0x000067B8 File Offset: 0x000049B8 + private void StartExport() + { + this.StopCountdown(); + this.exevent.Raise(); + base.Close(); + } + + // Token: 0x06000065 RID: 101 RVA: 0x000067D2 File Offset: 0x000049D2 + private void StopCountdown() + { + this.timer1.Stop(); + this.buttonNow.Enabled = false; + this.COUNTDOWN = 0; + } + + // Token: 0x06000066 RID: 102 RVA: 0x000067F2 File Offset: 0x000049F2 + private void timer1_Tick(object sender, EventArgs e) + { + this.COUNTDOWN--; + this.label1.Text = this.COUNTDOWN.ToString() + " 秒后开始导出"; + if (this.COUNTDOWN == 0) + { + this.StartExport(); + } + } + + // Token: 0x06000067 RID: 103 RVA: 0x00006830 File Offset: 0x00004A30 + private void buttonNow_Click(object sender, EventArgs e) + { + this.StartExport(); + } + + // Token: 0x06000068 RID: 104 RVA: 0x00006838 File Offset: 0x00004A38 + private void buttonCancel_Click(object sender, EventArgs e) + { + this.StopCountdown(); + base.Close(); + } + + // Token: 0x04000058 RID: 88 + private int COUNTDOWN; + + // Token: 0x04000059 RID: 89 + private ExternalEventHandler_Export handler; + + // Token: 0x0400005A RID: 90 + private ExternalEvent exevent; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/IfcExporterProcessMessage.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/IfcExporterProcessMessage.cs new file mode 100644 index 0000000..c4bc06b --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/IfcExporterProcessMessage.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000013 RID: 19 + public class IfcExporterProcessMessage + { + // Token: 0x1700000D RID: 13 + // (get) Token: 0x0600006B RID: 107 RVA: 0x00006AC9 File Offset: 0x00004CC9 + // (set) Token: 0x0600006C RID: 108 RVA: 0x00006AD1 File Offset: 0x00004CD1 + public IfcExporterProgcessStatus Status { get; set; } + + // Token: 0x1700000E RID: 14 + // (get) Token: 0x0600006D RID: 109 RVA: 0x00006ADA File Offset: 0x00004CDA + // (set) Token: 0x0600006E RID: 110 RVA: 0x00006AE2 File Offset: 0x00004CE2 + public CommonTaskStatus TaskStatus { get; set; } + + // Token: 0x1700000F RID: 15 + // (get) Token: 0x0600006F RID: 111 RVA: 0x00006AEB File Offset: 0x00004CEB + // (set) Token: 0x06000070 RID: 112 RVA: 0x00006AF3 File Offset: 0x00004CF3 + public Dictionary Arguments { get; set; } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/IfcExporterProgcessStatus.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/IfcExporterProgcessStatus.cs new file mode 100644 index 0000000..12d882c --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/IfcExporterProgcessStatus.cs @@ -0,0 +1,17 @@ +using System; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000011 RID: 17 + public enum IfcExporterProgcessStatus + { + // Token: 0x04000061 RID: 97 + NONE, + // Token: 0x04000062 RID: 98 + INIT, + // Token: 0x04000063 RID: 99 + START, + // Token: 0x04000064 RID: 100 + END + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/LinkInstance.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/LinkInstance.cs new file mode 100644 index 0000000..2712bbf --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/LinkInstance.cs @@ -0,0 +1,17 @@ +using System; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000015 RID: 21 + internal class LinkInstance + { + // Token: 0x04000071 RID: 113 + public string fileName; + + // Token: 0x04000072 RID: 114 + public string attachmentType; + + // Token: 0x04000073 RID: 115 + public MyTransform transform; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/LinkedFileManager.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/LinkedFileManager.cs new file mode 100644 index 0000000..1ac2162 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/LinkedFileManager.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Newtonsoft.Json; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000017 RID: 23 + [Transaction( TransactionMode.Manual)] + [Regeneration(0)] + public class LinkedFileManager : IExternalCommand + { + // Token: 0x06000075 RID: 117 RVA: 0x00006B8C File Offset: 0x00004D8C + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + Document document = commandData.Application.ActiveUIDocument.Document; + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.Title = "导出一级链接关系"; + saveFileDialog.Filter = "json files (*.json)|*.json"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + return LinkedFileManager.GetLinkFileInfo(document, saveFileDialog.FileName); + } + return (Result)1; + } + + // Token: 0x06000076 RID: 118 RVA: 0x00006BE0 File Offset: 0x00004DE0 + public static Result GetLinkFileInfo(Document doc, string resultPath) + { + List list = new FilteredElementCollector(doc).OfCategory((BuiltInCategory)(-2001352)).ToList(); + List list2 = new List(); + Result result; + try + { + foreach (Element element in list) + { + RevitLinkInstance revitLinkInstance = element as RevitLinkInstance; + if (revitLinkInstance != null) + { + RevitLinkType revitLinkType = doc.GetElement(revitLinkInstance.GetTypeId()) as RevitLinkType; + if (revitLinkType != null && !revitLinkType.IsNestedLink) + { + LinkInstance linkInstance = new LinkInstance(); + linkInstance.fileName = revitLinkType.Name; + linkInstance.attachmentType = revitLinkType.AttachmentType.ToString(); + Transform transform = revitLinkInstance.GetTransform(); + linkInstance.transform = new MyTransform(); + linkInstance.transform.basisX = new double[] + { + transform.BasisX.X, + transform.BasisX.Y, + transform.BasisX.Z + }; + linkInstance.transform.basisY = new double[] + { + transform.BasisY.X, + transform.BasisY.Y, + transform.BasisY.Z + }; + linkInstance.transform.basisZ = new double[] + { + transform.BasisZ.X, + transform.BasisZ.Y, + transform.BasisZ.Z + }; + linkInstance.transform.origin = new double[] + { + transform.Origin.X * 304.79999999999995, + transform.Origin.Y * 304.79999999999995, + transform.Origin.Z * 304.79999999999995 + }; + linkInstance.transform.scale = transform.Scale; + list2.Add(linkInstance); + } + } + } + File.WriteAllText(resultPath, JsonConvert.SerializeObject(new FileLinkInfo + { + linkInstances = list2, + fileName = Path.GetFileName(doc.PathName) + })); + result = 0; + } + catch (Exception) + { + result = (Result)(-1); + } + return result; + } + + // Token: 0x04000076 RID: 118 + private const double _inch_to_mm = 25.4; + + // Token: 0x04000077 RID: 119 + private const double _foot_to_mm = 304.79999999999995; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/MyTransform.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/MyTransform.cs new file mode 100644 index 0000000..bf8542e --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/MyTransform.cs @@ -0,0 +1,37 @@ +using System; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000014 RID: 20 + public class MyTransform + { + // Token: 0x06000072 RID: 114 RVA: 0x00006B04 File Offset: 0x00004D04 + public MyTransform() + { + double[] array = new double[3]; + array[0] = 1.0; + this.basisX = array; + double[] array2 = new double[3]; + array2[1] = 1.0; + this.basisY = array2; + this.basisZ = new double[] { 0.0, 0.0, 1.0 }; + this.origin = new double[3]; + this.scale = 1.0; + } + + // Token: 0x0400006C RID: 108 + public double[] basisX; + + // Token: 0x0400006D RID: 109 + public double[] basisY; + + // Token: 0x0400006E RID: 110 + public double[] basisZ; + + // Token: 0x0400006F RID: 111 + public double[] origin; + + // Token: 0x04000070 RID: 112 + public double scale; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/FormExportCountdown.resources b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/FormExportCountdown.resources new file mode 100644 index 0000000..6c05a97 Binary files /dev/null and b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/FormExportCountdown.resources differ diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/Comb.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/Comb.cs new file mode 100644 index 0000000..fc2798e --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/Comb.cs @@ -0,0 +1,41 @@ +using System; + +namespace IFC_Revit_Interop.NetCore.PostFix +{ + // Token: 0x02000024 RID: 36 + internal static class Comb + { + // Token: 0x06000096 RID: 150 RVA: 0x0000820C File Offset: 0x0000640C + public static long nCr(int n, int r) + { + return Comb.nPr(n, r) / Comb.Factorial(r); + } + + // Token: 0x06000097 RID: 151 RVA: 0x0000821C File Offset: 0x0000641C + public static long nPr(int n, int r) + { + return Comb.FactorialDivision(n, n - r); + } + + // Token: 0x06000098 RID: 152 RVA: 0x00008228 File Offset: 0x00006428 + private static long FactorialDivision(int topFactorial, int divisorFactorial) + { + long num = 1L; + for (int i = topFactorial; i > divisorFactorial; i--) + { + num *= (long)i; + } + return num; + } + + // Token: 0x06000099 RID: 153 RVA: 0x0000824A File Offset: 0x0000644A + private static long Factorial(int i) + { + if (i <= 1) + { + return 1L; + } + return (long)i * Comb.Factorial(i - 1); + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFixBase.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFixBase.cs new file mode 100644 index 0000000..c53ff00 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFixBase.cs @@ -0,0 +1,329 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using CBIMS.InterIFC.IFC; +using IFC_Revit_Interop.Utils; +using Revit.IFC.CBMod.Common.Extensions; +using Revit.IFC.CBMod.Export.Exporter.PropertySet; +using Revit.IFC.CBMod.Export.Utility; + +namespace IFC_Revit_Interop.NetCore.PostFix +{ + // Token: 0x02000025 RID: 37 + internal abstract class PostFixBase + { + // Token: 0x0600009A RID: 154 RVA: 0x00008260 File Offset: 0x00006460 + internal PostFixBase(Document doc, IModel imodel, string path) + { + this.doc = doc; + this.imodel = imodel; + this.path = path; + } + + // Token: 0x0600009B RID: 155 RVA: 0x000082BF File Offset: 0x000064BF + internal void Save() + { + this._flushClassification(); + this.imodel.Write(this.path); + } + + // Token: 0x0600009C RID: 156 + internal abstract void AddWires(); + + // Token: 0x0600009D RID: 157 + protected abstract IIfcFlowSegment _createWireSegment(Wire wire, IIfcProductDefinitionShape defShape); + + // Token: 0x0600009E RID: 158 + protected abstract IIfcRelDefinesByProperties _createIfcRelDefinesByProperties(IIfcObject obj, IIfcPropertySetDefinition pset); + + // Token: 0x0600009F RID: 159 + protected abstract IIfcClassification _createClassification(string classificationSource, string classificationEdition, string classificationName, int day, int month, int year); + + // Token: 0x060000A0 RID: 160 + protected abstract IIfcClassificationReference _createClassificationReference(IIfcClassification classification, string classificationCode, string classificationDescription, string location); + + // Token: 0x060000A1 RID: 161 + protected abstract IIfcRelAssociatesClassification _createRelAssociatesClassification(string key, List entsList, IIfcClassificationReference reference); + + // Token: 0x060000A2 RID: 162 RVA: 0x000082D8 File Offset: 0x000064D8 + internal static string _createConstIfcGuid(string for_what) + { + byte[] bytes = Encoding.Default.GetBytes(for_what); + byte[] array = MD5.Create().ComputeHash(bytes); + return IFCGuid.ToIfcGuid(new Guid(array)); + } + + // Token: 0x060000A3 RID: 163 RVA: 0x00008308 File Offset: 0x00006508 + internal string _getRevitName(Element elem) + { + string text = null; + string text2 = null; + FamilyInstance familyInstance = elem as FamilyInstance; + if (familyInstance != null) + { + text = familyInstance.Symbol.FamilyName; + text2 = familyInstance.Symbol.Name; + } + else if (elem.GetTypeId() != ElementId.InvalidElementId) + { + ElementType elementType = this.doc.GetElement(elem.GetTypeId()) as ElementType; + if (elementType != null) + { + text2 = elementType.Name; + text = "系统族:" + elementType.FamilyName; + } + } + return string.Format("{0}:{1}:{2}", text, text2, elem.Id.IntegerValue); + } + + // Token: 0x060000A4 RID: 164 RVA: 0x000083A0 File Offset: 0x000065A0 + internal static int[] _pointFromFeetToMM(XYZ p) + { + int num = (int)(p.X * 304.79999999999995); + int num2 = (int)(p.Y * 304.79999999999995); + int num3 = (int)(p.Z * 304.79999999999995); + return new int[] { num, num2, num3 }; + } + + // Token: 0x060000A5 RID: 165 RVA: 0x000083F8 File Offset: 0x000065F8 + internal List> _parseForCurves(GeometryElement geomElem, Transform transform) + { + List> list = new List>(); + if (geomElem == null) + { + return list; + } + foreach (GeometryObject geometryObject in geomElem) + { + if (!(geometryObject is Solid) && !(geometryObject is Face) && !(geometryObject is Mesh) && !(geometryObject is Profile)) + { + Curve curve = geometryObject as Curve; + if (curve == null) + { + PolyLine polyLine = geometryObject as PolyLine; + if (polyLine == null) + { + GeometryInstance geometryInstance = geometryObject as GeometryInstance; + if (geometryInstance == null) + { + this.log.Write("GEOM", "Unknown Geometry " + geometryObject.GetType().FullName); + } + else + { + Transform transform2 = geometryInstance.Transform; + GeometryElement symbolGeometry = geometryInstance.SymbolGeometry; + List> list2 = this._parseForCurves(symbolGeometry, transform2); + list.AddRange(list2); + } + } + else + { + List list3 = new List(); + foreach (XYZ xyz in polyLine.GetCoordinates()) + { + list3.Add(PostFixBase._pointFromFeetToMM(xyz)); + } + list.Add(list3); + } + } + else + { + List list4 = new List(); + foreach (XYZ xyz2 in curve.Tessellate()) + { + list4.Add(PostFixBase._pointFromFeetToMM(xyz2)); + } + list.Add(list4); + } + } + } + if (transform != null) + { + List> list5 = new List>(); + foreach (List list6 in list) + { + List list7 = new List(); + foreach (int[] array in list6) + { + XYZ xyz3 = transform.OfPoint(new XYZ((double)array[0], (double)array[1], (double)array[2])); + list7.Add(PostFixBase._pointFromFeetToMM(xyz3)); + } + list5.Add(list7); + } + return list5; + } + return list; + } + + // Token: 0x060000A6 RID: 166 RVA: 0x000086A0 File Offset: 0x000068A0 + internal string _elementIdParameterAsString(Parameter parameter) + { + ElementId elementId = parameter.AsElementId(); + if (elementId == ElementId.InvalidElementId) + { + return null; + } + string text; + if (elementId.IntegerValue >= 0) + { + Element element = this.doc.GetElement(elementId); + text = ((element != null) ? element.Name : null); + if (!string.IsNullOrEmpty(text)) + { + ElementType elementType = ((element is ElementType) ? (element as ElementType) : (this.doc.GetElement(element.GetTypeId()) as ElementType)); + string text2 = ((elementType != null) ? elementType.FamilyName : null); + if (!string.IsNullOrEmpty(text2)) + { + text = text2 + ": " + text; + } + } + } + else + { + text = parameter.AsValueString(); + } + if (string.IsNullOrEmpty(text)) + { + text = elementId.ToString(); + } + return text; + } + + // Token: 0x060000A7 RID: 167 RVA: 0x00008758 File Offset: 0x00006958 + public void CreateClassification(Element element, IIfcObjectDefinition elemHnd) + { + if (elemHnd == null) + { + return; + } + string text = ""; + string text2 = "ClassificationCode"; + new List(); + string text3 = null; + string text4 = null; + string text5 = null; + int num = 0; + int i = 1; + int count = ExporterCacheManager.ClassificationCache.CustomClassificationCodeNames.Count; + while (i <= 10) + { + string text6; + if (num < count) + { + text6 = ExporterCacheManager.ClassificationCache.CustomClassificationCodeNames[num]; + num++; + if (string.IsNullOrWhiteSpace(text6)) + { + continue; + } + } + else + { + text6 = text2; + if (i > 1) + { + text6 = text6 + "(" + i.ToString() + ")"; + } + i++; + } + if (ParameterUtil.GetStringValueFromElementOrSymbol(element, text6, out text) != null) + { + ClassificationUtil.parseClassificationCode(text, text6, out text3, out text4, out text5); + if (!string.IsNullOrEmpty(text3)) + { + IIfcClassification ifcClassification; + if (!this._classificationHandleCache.TryGetValue(text3, out ifcClassification)) + { + IFCClassification ifcclassification = new IFCClassification(); + if (ExporterCacheManager.ClassificationCache.ClassificationsByName.TryGetValue(text3, out ifcclassification)) + { + DateTime classificationEditionDate = ifcclassification.ClassificationEditionDate; + ifcClassification = this._createClassification(ifcclassification.ClassificationSource, ifcclassification.ClassificationEdition, ifcclassification.ClassificationName, ifcclassification.ClassificationEditionDate.Day, ifcclassification.ClassificationEditionDate.Month, ifcclassification.ClassificationEditionDate.Year); + if (!string.IsNullOrEmpty(ifcclassification.ClassificationLocation)) + { + this._classificationLocationCache.Add(text3, ifcclassification.ClassificationLocation); + } + } + else + { + ifcClassification = this._createClassification("", "", text3, 0, 0, 0); + } + this._classificationHandleCache.Add(text3, ifcClassification); + } + string text7 = null; + this._classificationLocationCache.TryGetValue(text3, out text7); + if (!string.IsNullOrEmpty(text4)) + { + string text8 = text3 + ":" + text4; + if (!this._classificationReferenceCache.ContainsKey(text8)) + { + IIfcClassificationReference ifcClassificationReference = this._createClassificationReference(ifcClassification, text4, text5, text7); + this._classificationReferenceCache[text8] = ifcClassificationReference; + this._classificationAssociateCache[text8] = new HashSet(); + } + this._classificationAssociateCache[text8].Add(elemHnd); + } + } + } + } + } + + // Token: 0x060000A8 RID: 168 RVA: 0x00008970 File Offset: 0x00006B70 + public void _flushClassification() + { + foreach (string text in this._classificationReferenceCache.Keys) + { + IIfcClassificationReference ifcClassificationReference = this._classificationReferenceCache[text]; + HashSet hashSet = this._classificationAssociateCache[text]; + if (hashSet.Any()) + { + List list = hashSet.ToList(); + list.Sort((IIfcObjectDefinition x, IIfcObjectDefinition y) => x.GlobalId.CompareTo(y.GlobalId)); + this._createRelAssociatesClassification(text, list, ifcClassificationReference); + } + } + this._classificationReferenceCache.Clear(); + this._classificationAssociateCache.Clear(); + } + + // Token: 0x060000A9 RID: 169 RVA: 0x00008A34 File Offset: 0x00006C34 + internal static DisplayUnitType _getUnitTypeId(Parameter parameter) + { + return parameter.DisplayUnitType; + } + + // Token: 0x04000096 RID: 150 + protected Document doc; + + // Token: 0x04000097 RID: 151 + protected IModel imodel; + + // Token: 0x04000098 RID: 152 + protected string path; + + // Token: 0x04000099 RID: 153 + protected Log log = App_IFCExporter_StartUp.log; + + // Token: 0x0400009A RID: 154 + internal const double _inch_to_mm = 25.4; + + // Token: 0x0400009B RID: 155 + internal const double _foot_to_mm = 304.79999999999995; + + // Token: 0x0400009C RID: 156 + private Dictionary _classificationHandleCache = new Dictionary(); + + // Token: 0x0400009D RID: 157 + private Dictionary _classificationLocationCache = new Dictionary(); + + // Token: 0x0400009E RID: 158 + private Dictionary _classificationReferenceCache = new Dictionary(); + + // Token: 0x0400009F RID: 159 + private Dictionary> _classificationAssociateCache = new Dictionary>(); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFix_IFC2x3.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFix_IFC2x3.cs new file mode 100644 index 0000000..1b3aef5 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFix_IFC2x3.cs @@ -0,0 +1,790 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using CBIMS.InterIFC.IFC; +using CBIMS.STEParser.EB.IFC2X3; +using IFC_Revit_Interop.Utils; +using Revit.IFC.CBMod.Export.Utility; + +namespace IFC_Revit_Interop.NetCore.PostFix +{ + // Token: 0x02000026 RID: 38 + internal class PostFix_IFC2x3 : PostFixBase + { + // Token: 0x17000010 RID: 16 + // (get) Token: 0x060000AA RID: 170 RVA: 0x00008A3C File Offset: 0x00006C3C + private Model model + { + get + { + return this.imodel as Model; + } + } + + // Token: 0x060000AB RID: 171 RVA: 0x00008A4C File Offset: 0x00006C4C + internal PostFix_IFC2x3(Document doc, Model model, string path) + : base(doc, model, path) + { + this.context_body = (from t in model.FindAll(true) + where t.ContextIdentifier == "Body" && t.ContextType == "Model" + select t).FirstOrDefault(); + if (this.context_body == null) + { + this.context_body = model.FindAll(true).FirstOrDefault(); + } + this.ownerHistory = model.FindAll(true).FirstOrDefault(); + this._initAvailableIfcValues(); + } + + // Token: 0x060000AC RID: 172 RVA: 0x00008AE0 File Offset: 0x00006CE0 + private void _initAvailableIfcValues() + { + foreach (MethodInfo methodInfo in typeof(IfcValue).GetMethods()) + { + if (methodInfo.Name.StartsWith("SetIfc")) + { + string text = methodInfo.Name.Substring(3).ToUpperInvariant(); + ParameterInfo parameterInfo = methodInfo.GetParameters().FirstOrDefault(); + if (parameterInfo != null) + { + if (parameterInfo.ParameterType == typeof(double)) + { + this.doubleIfcValues[text] = methodInfo; + } + else if (parameterInfo.ParameterType == typeof(string)) + { + this.stringIfcValues[text] = methodInfo; + } + } + } + } + } + + // Token: 0x060000AD RID: 173 RVA: 0x00008B98 File Offset: 0x00006D98 + internal override void AddWires() + { + FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.doc).OfClass(typeof(Wire)); + Dictionary dictionary = new Dictionary(); + Dictionary> dictionary2 = new Dictionary>(); + new Options().DetailLevel = (ViewDetailLevel)2; + foreach (Element element in filteredElementCollector) + { + Wire wire = (Wire)element; + int num = 2; + List list = new List(); + if (wire.WiringType == (WiringType)1) + { + for (int i = 0; i < wire.NumberOfVertices; i++) + { + XYZ vertex = wire.GetVertex(i); + list.Add(PostFixBase._pointFromFeetToMM(vertex)); + } + } + else + { + if (wire.WiringType != null) + { + throw new NotImplementedException(); + } + int num2 = wire.NumberOfVertices - 1; + double num3 = 0.33333333333333331 / (double)num2; + for (double num4 = 0.0; num4 < 1.0 + num3 / 10.0; num4 += num3) + { + double[] array = new double[3]; + for (int j = 0; j <= num2; j++) + { + XYZ vertex2 = wire.GetVertex(j); + double num5 = (double)Comb.nCr(num2, j); + double num6 = 1.0; + double num7 = 1.0; + if (j != num2) + { + num6 = Math.Pow(1.0 - num4, (double)(num2 - j)); + } + if (j != 0) + { + num7 = Math.Pow(num4, (double)j); + } + double num8 = num5 * num6 * num7; + array[0] += num8 * vertex2.X; + array[1] += num8 * vertex2.Y; + array[2] += num8 * vertex2.Z; + } + list.Add(PostFixBase._pointFromFeetToMM(new XYZ(array[0], array[1], array[2]))); + } + } + List list2 = new List(); + foreach (int[] array2 in list) + { + list2.Add(this.model.Create.CreateIfcCartesianPoint(new double[] + { + (double)array2[0], + (double)array2[1], + (double)array2[2] + })); + } + IfcPolyline ifcPolyline = this.model.Create.CreateIfcPolyline(list2); + IfcSweptDiskSolid ifcSweptDiskSolid = this.model.Create.CreateIfcSweptDiskSolid(ifcPolyline, (double)num, null, 0.0, (double)(list2.Count - 1)); + List list3 = new List { ifcSweptDiskSolid }; + IfcShapeRepresentation ifcShapeRepresentation = this.model.Create.CreateIfcShapeRepresentation(this.context_body, "Body", "SweptSolid", list3); + IfcProductDefinitionShape ifcProductDefinitionShape = this.model.Create.CreateIfcProductDefinitionShape(null, null, new List { ifcShapeRepresentation }); + IIfcFlowSegment ifcFlowSegment = this._createWireSegment(wire, ifcProductDefinitionShape); + ElementId typeId = wire.GetTypeId(); + if (!dictionary.ContainsKey(typeId.IntegerValue)) + { + Element element2 = this.doc.GetElement(typeId); + string text = element2.IfcGUID(); + List list4 = this._makeInternalRevitPsets(element2); + IfcCableSegmentType ifcCableSegmentType = this.model.Create.CreateIfcCableSegmentType(text, this.ownerHistory, element2.Name, null, null, list4, null, typeId.ToString(), null, IfcCableSegmentTypeEnum.CABLESEGMENT); + dictionary[typeId.IntegerValue] = ifcCableSegmentType; + dictionary2[typeId.IntegerValue] = new List(); + } + dictionary2[typeId.IntegerValue].Add(ifcFlowSegment as IfcObject); + foreach (IfcPropertySetDefinition ifcPropertySetDefinition in this._makeInternalRevitPsets(wire)) + { + this._createIfcRelDefinesByProperties(ifcFlowSegment as IfcObject, ifcPropertySetDefinition); + } + base.CreateClassification(wire, ifcFlowSegment as IfcObject); + } + foreach (int num9 in dictionary2.Keys) + { + IfcElementType ifcElementType = dictionary[num9]; + List list5 = dictionary2[num9].ToList(); + list5.Sort((IfcObject x, IfcObject y) => x.GlobalId.CompareTo(y.GlobalId)); + this.model.Create.CreateIfcRelDefinesByType(PostFixBase._createConstIfcGuid(ifcElementType.GlobalId + " RelToInsts"), this.ownerHistory, null, null, list5, ifcElementType); + } + } + + // Token: 0x060000AE RID: 174 RVA: 0x0000909C File Offset: 0x0000729C + private List _makeInternalRevitPsets(Element whichElement) + { + List list = new List(); + Dictionary> dictionary = new Dictionary>(); + ElementId id = whichElement.Id; + foreach (KeyValuePair keyValuePair in this._getNonIFCParametersForElement(whichElement)) + { + string text = LabelUtils.GetLabelFor(keyValuePair.Key); + if (whichElement is ElementType) + { + text += "(Type)"; + } + HashSet hashSet = new HashSet(); + dictionary[text] = hashSet; + foreach (Parameter parameter in keyValuePair.Value.ParameterCache.Values) + { + if (parameter.HasValue) + { + Definition definition = parameter.Definition; + if (definition != null) + { + string name = definition.Name; + switch (parameter.StorageType) + { + case (StorageType)1: + { + int num = parameter.AsInteger(); + string text2 = parameter.AsValueString(); + if (definition.ParameterType == (ParameterType)10) + { + hashSet.Add(this._createBooleanProperty(name, num != 0)); + } + else if (definition.ParameterType == null && text2 != null) + { + hashSet.Add(this._createIdentifierProperty(name, text2)); + } + else + { + hashSet.Add(this._createIntegerProperty(name, num)); + } + break; + } + case (StorageType)2: + { + double num2 = parameter.AsDouble(); + ParameterType parameterType = definition.ParameterType; + IfcProperty ifcProperty; + switch (parameterType) + { + case (ParameterType)4: + goto IL_0370; + case (ParameterType)5: + goto IL_0356; + case (ParameterType)6: + goto IL_063B; + case (ParameterType)7: + ifcProperty = this._createPlaneAngleMeasureProperty(name, UnitUtil.ScaleAngle(num2)); + break; + case (ParameterType)8: + case (ParameterType)9: + case (ParameterType)10: + goto IL_0652; + case (ParameterType)11: + { + double num3 = UnitUtil.ScaleForce(num2); + ifcProperty = this._createForceProperty(name, num3); + break; + } + default: + switch (parameterType) + { + case (ParameterType)109: + { + double num4 = UnitUtil.ScaleDouble((UnitType)9, num2); + IfcValue ifcValue = this._createDoubleMeasure(num4, "IfcReal"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue, "FRICTIONLOSS"); + break; + } + case (ParameterType)110: + case (ParameterType)118: + case (ParameterType)124: + case (ParameterType)134: + case (ParameterType)160: + case (ParameterType)163: + case (ParameterType)174: + { + double num5 = UnitUtil.ScalePower(num2); + ifcProperty = this._createPowerProperty(name, num5); + break; + } + case (ParameterType)111: + case (ParameterType)126: + case (ParameterType)127: + case (ParameterType)128: + case (ParameterType)129: + case (ParameterType)130: + case (ParameterType)131: + case (ParameterType)132: + case (ParameterType)133: + case (ParameterType)135: + case (ParameterType)136: + case (ParameterType)138: + case (ParameterType)142: + case (ParameterType)146: + case (ParameterType)147: + case (ParameterType)148: + case (ParameterType)149: + case (ParameterType)150: + case (ParameterType)151: + case (ParameterType)152: + case (ParameterType)153: + case (ParameterType)154: + case (ParameterType)156: + case (ParameterType)157: + case (ParameterType)158: + case (ParameterType)159: + case (ParameterType)161: + case (ParameterType)162: + case (ParameterType)164: + case (ParameterType)165: + case (ParameterType)166: + case (ParameterType)167: + case (ParameterType)168: + case (ParameterType)170: + case (ParameterType)171: + case (ParameterType)176: + case (ParameterType)178: + case (ParameterType)179: + case (ParameterType)180: + case (ParameterType)186: + case (ParameterType)190: + case (ParameterType)191: + case (ParameterType)192: + case (ParameterType)196: + case (ParameterType)197: + case (ParameterType)199: + case (ParameterType)202: + case (ParameterType)203: + case (ParameterType)205: + case (ParameterType)208: + goto IL_0652; + case (ParameterType)112: + case (ParameterType)139: + case (ParameterType)145: + { + double num6 = UnitUtil.ScaleDouble((UnitType)12, num2); + IfcValue ifcValue2 = this._createDoubleMeasure(num6, "IfcPressureMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue2, null); + break; + } + case (ParameterType)113: + case (ParameterType)140: + case (ParameterType)181: + { + double num7 = UnitUtil.ScaleDouble((UnitType)13, num2); + IfcValue ifcValue3 = this._createDoubleMeasure(num7, "IfcThermalTransmittanceMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue3, null); + break; + } + case (ParameterType)114: + case (ParameterType)141: + { + double num8 = UnitUtil.ScaleDouble((UnitType)14, num2); + IfcValue ifcValue4 = this._createDoubleMeasure(num8, "IfcLinearVelocityMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue4, null); + break; + } + case (ParameterType)115: + case (ParameterType)137: + { + double num9 = UnitUtil.ScaleVolumetricFlowRate(num2); + ifcProperty = this._createVolumetricFlowRateMeasureProperty(name, num9); + break; + } + case (ParameterType)116: + case (ParameterType)125: + case (ParameterType)143: + case (ParameterType)144: + case (ParameterType)169: + case (ParameterType)182: + case (ParameterType)183: + case (ParameterType)185: + case (ParameterType)187: + case (ParameterType)188: + case (ParameterType)189: + case (ParameterType)193: + case (ParameterType)194: + case (ParameterType)195: + case (ParameterType)201: + case (ParameterType)206: + case (ParameterType)207: + case (ParameterType)210: + case (ParameterType)212: + goto IL_0370; + case (ParameterType)117: + case (ParameterType)204: + case (ParameterType)209: + goto IL_0356; + case (ParameterType)119: + { + double num10 = UnitUtil.ScaleElectricCurrent(num2); + ifcProperty = this._createElectricCurrentMeasureProperty(name, num10); + break; + } + case (ParameterType)120: + { + double num11 = UnitUtil.ScaleElectricVoltage(num2); + ifcProperty = this._createElectricVoltageMeasureProperty(name, num11); + break; + } + case (ParameterType)121: + ifcProperty = this._createFrequencyProperty(name, num2); + break; + case (ParameterType)122: + { + double num12 = UnitUtil.ScaleIlluminance(num2); + ifcProperty = this._createIlluminanceProperty(name, num12); + break; + } + case (ParameterType)123: + { + double num13 = UnitUtil.ScaleLuminousFlux(num2); + ifcProperty = this._createLuminousFluxMeasureProperty(name, num13); + break; + } + case (ParameterType)155: + case (ParameterType)184: + case (ParameterType)211: + goto IL_063B; + case (ParameterType)172: + { + IfcValue ifcValue5 = (this.doubleIfcValues.ContainsKey("IFCMONETARYMEASURE") ? this._createDoubleMeasure(num2, "IfcMonetaryMeasure") : this._createDoubleMeasure(num2, "IfcReal")); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue5, null); + break; + } + case (ParameterType)173: + { + double num14 = UnitUtil.ScaleDouble((UnitType)73, num2); + IfcValue ifcValue6 = this._createDoubleMeasure(num14, "IfcReal"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue6, "LUMINOUSEFFICACY"); + break; + } + case (ParameterType)175: + { + double num15 = UnitUtil.ScaleDouble((UnitType)75, num2); + IfcValue ifcValue7 = this._createDoubleMeasure(num15, "IfcReal"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue7, "COLORTEMPERATURE"); + break; + } + case (ParameterType)177: + { + double num16 = UnitUtil.ScaleLuminousIntensity(num2); + ifcProperty = this._createLuminousIntensityProperty(name, num16); + break; + } + case (ParameterType)198: + { + double num17 = UnitUtil.ScaleDouble((UnitType)98, num2); + IfcValue ifcValue8 = this._createDoubleMeasure(num17, "IfcMassMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue8, null); + break; + } + case (ParameterType)200: + { + double num18 = UnitUtil.ScaleDouble((UnitType)100, num2); + IfcValue ifcValue9 = this._createDoubleMeasure(num18, "IfcMomentofInertiaMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue9, null); + break; + } + default: + { + if (parameterType != (ParameterType)222) + { + goto IL_0652; + } + double num19 = UnitUtil.ScaleDouble((UnitType)122, num2); + IfcValue ifcValue10 = this._createDoubleMeasure(num19, "IfcMassDensityMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue10, null); + break; + } + } + break; + } + IL_0677: + if (ifcProperty != null) + { + hashSet.Add(ifcProperty); + break; + } + break; + IL_0370: + ifcProperty = this._createLengthMeasureProperty(name, UnitUtil.ScaleLength(num2)); + goto IL_0677; + IL_0356: + double num20 = UnitUtil.ScaleArea(num2); + ifcProperty = this._createAreaMeasureProperty(name, num20); + goto IL_0677; + IL_063B: + double num21 = UnitUtil.ScaleVolume(num2); + ifcProperty = this._createVolumeMeasureProperty(name, num21); + goto IL_0677; + IL_0652: + double num22 = num2; + try + { + num22 = UnitUtils.ConvertFromInternalUnits(num2, PostFixBase._getUnitTypeId(parameter)); + } + catch + { + } + ifcProperty = this._createRealProperty(name, num22); + goto IL_0677; + } + case (StorageType)3: + { + string text3 = parameter.AsString(); + hashSet.Add(this._createTextProperty(name, text3)); + break; + } + case (StorageType)4: + if (!(parameter.AsElementId() == ElementId.InvalidElementId)) + { + string text4 = base._elementIdParameterAsString(parameter); + hashSet.Add(this._createLabelProperty(name, text4)); + } + break; + } + } + } + } + } + foreach (string text5 in dictionary.Keys) + { + List list2 = dictionary[text5].Where((IfcProperty t) => t != null).ToList(); + if (list2.Any()) + { + IfcPropertySet ifcPropertySet = this.model.Create.CreateIfcPropertySet(PostFixBase._createConstIfcGuid("Pset " + text5 + " of " + whichElement.IfcGUID()), this.ownerHistory, text5, null, list2); + list.Add(ifcPropertySet); + } + } + return list; + } + + // Token: 0x060000AF RID: 175 RVA: 0x000098C8 File Offset: 0x00007AC8 + private IfcValue _createDoubleMeasure(double value, string measureName) + { + string text = measureName.ToUpperInvariant(); + if (this.doubleIfcValues.ContainsKey(text)) + { + return this.doubleIfcValues[text].Invoke(null, new object[] { value }) as IfcValue; + } + return null; + } + + // Token: 0x060000B0 RID: 176 RVA: 0x00009914 File Offset: 0x00007B14 + private IfcValue _createStringMeasure(string value, string measureName) + { + string text = measureName.ToUpperInvariant(); + if (this.stringIfcValues.ContainsKey(text)) + { + return this.stringIfcValues[text].Invoke(null, new object[] { value }) as IfcValue; + } + return null; + } + + // Token: 0x060000B1 RID: 177 RVA: 0x00009959 File Offset: 0x00007B59 + private IfcPropertySingleValue _createCommonPropertySingleValue(string parameterCaption, IfcValue nominalValue, string unitKey) + { + if (nominalValue == null) + { + return null; + } + return this.model.Create.CreateIfcPropertySingleValue(parameterCaption, null, nominalValue, null); + } + + // Token: 0x060000B2 RID: 178 RVA: 0x00009974 File Offset: 0x00007B74 + private IfcProperty _createForceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcForceMeasure(scaledValue), null); + } + + // Token: 0x060000B3 RID: 179 RVA: 0x00009984 File Offset: 0x00007B84 + private IfcProperty _createElectricCurrentMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcElectricCurrentMeasure(scaledValue), null); + } + + // Token: 0x060000B4 RID: 180 RVA: 0x00009994 File Offset: 0x00007B94 + private IfcProperty _createFrequencyProperty(string parameterCaption, double value) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcFrequencyMeasure(value), null); + } + + // Token: 0x060000B5 RID: 181 RVA: 0x000099A4 File Offset: 0x00007BA4 + private IfcProperty _createElectricVoltageMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcElectricVoltageMeasure(scaledValue), null); + } + + // Token: 0x060000B6 RID: 182 RVA: 0x000099B4 File Offset: 0x00007BB4 + private IfcProperty _createLuminousIntensityProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLuminousIntensityMeasure(scaledValue), null); + } + + // Token: 0x060000B7 RID: 183 RVA: 0x000099C4 File Offset: 0x00007BC4 + private IfcProperty _createPlanarForceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcPlanarForceMeasure(scaledValue), null); + } + + // Token: 0x060000B8 RID: 184 RVA: 0x000099D4 File Offset: 0x00007BD4 + private IfcProperty _createLinearForceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLinearForceMeasure(scaledValue), null); + } + + // Token: 0x060000B9 RID: 185 RVA: 0x000099E4 File Offset: 0x00007BE4 + private IfcProperty _createVolumetricFlowRateMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcVolumetricFlowRateMeasure(scaledValue), null); + } + + // Token: 0x060000BA RID: 186 RVA: 0x000099F4 File Offset: 0x00007BF4 + private IfcProperty _createVolumeMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcVolumeMeasure(scaledValue), null); + } + + // Token: 0x060000BB RID: 187 RVA: 0x00009A04 File Offset: 0x00007C04 + private IfcProperty _createRealProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcReal(scaledValue), null); + } + + // Token: 0x060000BC RID: 188 RVA: 0x00009A14 File Offset: 0x00007C14 + private IfcProperty _createLuminousFluxMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLuminousFluxMeasure(scaledValue), null); + } + + // Token: 0x060000BD RID: 189 RVA: 0x00009A24 File Offset: 0x00007C24 + private IfcProperty _createIlluminanceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcIlluminanceMeasure(scaledValue), null); + } + + // Token: 0x060000BE RID: 190 RVA: 0x00009A34 File Offset: 0x00007C34 + private IfcProperty _createAreaMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcAreaMeasure(scaledValue), null); + } + + // Token: 0x060000BF RID: 191 RVA: 0x00009A44 File Offset: 0x00007C44 + private IfcProperty _createLengthMeasureProperty(string parameterCaption, double v) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLengthMeasure(v), null); + } + + // Token: 0x060000C0 RID: 192 RVA: 0x00009A54 File Offset: 0x00007C54 + private IfcProperty _createPowerProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcPowerMeasure(scaledValue), null); + } + + // Token: 0x060000C1 RID: 193 RVA: 0x00009A64 File Offset: 0x00007C64 + private IfcProperty _createPlaneAngleMeasureProperty(string parameterCaption, double v) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcPlaneAngleMeasure(v), null); + } + + // Token: 0x060000C2 RID: 194 RVA: 0x00009A74 File Offset: 0x00007C74 + private IfcProperty _createIntegerProperty(string parameterCaption, int value) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcInteger(value), null); + } + + // Token: 0x060000C3 RID: 195 RVA: 0x00009A84 File Offset: 0x00007C84 + private IfcProperty _createIdentifierProperty(string parameterCaption, string valueAsString) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcIdentifier(valueAsString), null); + } + + // Token: 0x060000C4 RID: 196 RVA: 0x00009A94 File Offset: 0x00007C94 + private IfcProperty _createLabelProperty(string parameterCaption, string valueString) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLabel(valueString), null); + } + + // Token: 0x060000C5 RID: 197 RVA: 0x00009AA4 File Offset: 0x00007CA4 + private IfcProperty _createTextProperty(string parameterCaption, string value) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcText(value), null); + } + + // Token: 0x060000C6 RID: 198 RVA: 0x00009AB4 File Offset: 0x00007CB4 + private IfcProperty _createBooleanProperty(string parameterCaption, bool v) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcBoolean(v), null); + } + + // Token: 0x060000C7 RID: 199 RVA: 0x00009AC4 File Offset: 0x00007CC4 + private IDictionary _getNonIFCParametersForElement(Element element) + { + IDictionary dictionary = new Dictionary(); + ParameterSet parameters = element.Parameters; + if (parameters.Size == 0) + { + return dictionary; + } + IDictionary> dictionary2 = new SortedDictionary>(); + ParameterSetIterator parameterSetIterator = parameters.ForwardIterator(); + while (parameterSetIterator.MoveNext()) + { + object obj = parameterSetIterator.Current; + Parameter parameter = obj as Parameter; + if (parameter != null && !PostFix_IFC2x3._isDuplicateParameter(parameter)) + { + Definition definition = parameter.Definition; + if (definition != null) + { + InternalDefinition internalDefinition = definition as InternalDefinition; + if (internalDefinition == null || internalDefinition.Visible) + { + string name = definition.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + dictionary2[parameter.Id.IntegerValue] = new KeyValuePair(name, parameter); + } + } + } + } + } + foreach (KeyValuePair keyValuePair in dictionary2.Values) + { + Parameter value = keyValuePair.Value; + Definition definition2 = value.Definition; + string key = keyValuePair.Key; + BuiltInParameterGroup parameterGroup = definition2.ParameterGroup; + ParameterElementCache parameterElementCache = null; + if (parameterGroup != (BuiltInParameterGroup)(-5000131)) + { + if (!dictionary.TryGetValue(parameterGroup, out parameterElementCache)) + { + parameterElementCache = new ParameterElementCache(); + dictionary[parameterGroup] = parameterElementCache; + } + } + else if (!dictionary.TryGetValue(parameterGroup, out parameterElementCache)) + { + parameterElementCache = new ParameterElementCache(); + dictionary[parameterGroup] = parameterElementCache; + } + if (parameterElementCache != null && (!parameterElementCache.ParameterCache.ContainsKey(key) || !parameterElementCache.ParameterCache[key].HasValue)) + { + parameterElementCache.ParameterCache[key] = value; + } + } + return dictionary; + } + + // Token: 0x060000C8 RID: 200 RVA: 0x00009C50 File Offset: 0x00007E50 + private static bool _isDuplicateParameter(Parameter parameter) + { + return parameter.Id.IntegerValue == -1140363 || parameter.Id.IntegerValue == -1001125; + } + + // Token: 0x060000C9 RID: 201 RVA: 0x00009C7C File Offset: 0x00007E7C + protected override IIfcFlowSegment _createWireSegment(Wire wire, IIfcProductDefinitionShape defShape) + { + string text = wire.IfcGUID(); + string text2 = base._getRevitName(wire); + string text3 = wire.Id.IntegerValue.ToString(); + ElementId typeId = wire.GetTypeId(); + Element element = wire.Document.GetElement(typeId); + string text4 = null; + if (element != null) + { + text4 = element.Name; + } + return this.model.Create.CreateIfcFlowSegment(text, this.ownerHistory, text2, null, text4, null, defShape as IfcProductDefinitionShape, text3); + } + + // Token: 0x060000CA RID: 202 RVA: 0x00009CF8 File Offset: 0x00007EF8 + protected override IIfcRelDefinesByProperties _createIfcRelDefinesByProperties(IIfcObject obj, IIfcPropertySetDefinition pset) + { + string text = PostFixBase._createConstIfcGuid(obj.GlobalId + " RelToPset " + pset.Name); + return this.model.Create.CreateIfcRelDefinesByProperties(text, this.ownerHistory, null, null, new List { obj as IfcObject }, pset as IfcPropertySetDefinition); + } + + // Token: 0x060000CB RID: 203 RVA: 0x00009D54 File Offset: 0x00007F54 + protected override IIfcClassification _createClassification(string classificationSource, string classificationEdition, string classificationName, int day, int month, int year) + { + IIfcCalendarDate ifcCalendarDate = null; + if (day > 0 && month > 0 && year > 0) + { + ifcCalendarDate = this.model.Create.CreateIfcCalendarDate(day, month, year); + } + return this.model.Create.CreateIfcClassification(classificationSource, classificationEdition, ifcCalendarDate as IfcCalendarDate, classificationName); + } + + // Token: 0x060000CC RID: 204 RVA: 0x00009DA2 File Offset: 0x00007FA2 + protected override IIfcClassificationReference _createClassificationReference(IIfcClassification classification, string classificationCode, string classificationDescription, string location) + { + return this.model.Create.CreateIfcClassificationReference(location, classificationCode, classificationDescription, classification as IfcClassification); + } + + // Token: 0x060000CD RID: 205 RVA: 0x00009DC0 File Offset: 0x00007FC0 + protected override IIfcRelAssociatesClassification _createRelAssociatesClassification(string key, List entsList, IIfcClassificationReference reference) + { + string text = PostFixBase._createConstIfcGuid("relAssoClass for " + key); + int num = key.IndexOf(':'); + string text2 = key.Substring(0, num) + " Classification"; + return this.model.Create.CreateIfcRelAssociatesClassification(text, this.ownerHistory, text2, null, entsList.Cast().ToList(), reference as IfcClassificationReference); + } + + // Token: 0x040000A0 RID: 160 + private IfcGeometricRepresentationContext context_body; + + // Token: 0x040000A1 RID: 161 + private IfcOwnerHistory ownerHistory; + + // Token: 0x040000A2 RID: 162 + private Dictionary doubleIfcValues = new Dictionary(); + + // Token: 0x040000A3 RID: 163 + private Dictionary stringIfcValues = new Dictionary(); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFix_IFC4.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFix_IFC4.cs new file mode 100644 index 0000000..9c2680c --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/PostFix/PostFix_IFC4.cs @@ -0,0 +1,801 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Electrical; +using CBIMS.InterIFC.IFC; +using CBIMS.STEParser.EB.IFC4; +using IFC_Revit_Interop.Utils; +using Revit.IFC.CBMod.Export.Utility; + +namespace IFC_Revit_Interop.NetCore.PostFix +{ + // Token: 0x02000027 RID: 39 + internal class PostFix_IFC4 : PostFixBase + { + // Token: 0x17000011 RID: 17 + // (get) Token: 0x060000CE RID: 206 RVA: 0x00009E29 File Offset: 0x00008029 + private Model model + { + get + { + return this.imodel as Model; + } + } + + // Token: 0x060000CF RID: 207 RVA: 0x00009E38 File Offset: 0x00008038 + internal PostFix_IFC4(Document doc, Model model, string path) + : base(doc, model, path) + { + this.context_body = (from t in model.FindAll(true) + where t.ContextIdentifier == "Body" && t.ContextType == "Model" + select t).FirstOrDefault(); + if (this.context_body == null) + { + this.context_body = model.FindAll(true).FirstOrDefault(); + } + this.ownerHistory = model.FindAll(true).FirstOrDefault(); + this._initAvailableIfcValues(); + } + + // Token: 0x060000D0 RID: 208 RVA: 0x00009ECC File Offset: 0x000080CC + private void _initAvailableIfcValues() + { + foreach (MethodInfo methodInfo in typeof(IfcValue).GetMethods()) + { + if (methodInfo.Name.StartsWith("SetIfc")) + { + string text = methodInfo.Name.Substring(3).ToUpperInvariant(); + ParameterInfo parameterInfo = methodInfo.GetParameters().FirstOrDefault(); + if (parameterInfo != null) + { + if (parameterInfo.ParameterType == typeof(double)) + { + this.doubleIfcValues[text] = methodInfo; + } + else if (parameterInfo.ParameterType == typeof(string)) + { + this.stringIfcValues[text] = methodInfo; + } + } + } + } + } + + // Token: 0x060000D1 RID: 209 RVA: 0x00009F84 File Offset: 0x00008184 + internal override void AddWires() + { + FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.doc).OfClass(typeof(Wire)); + Dictionary dictionary = new Dictionary(); + Dictionary> dictionary2 = new Dictionary>(); + new Options().DetailLevel = (ViewDetailLevel)2; + foreach (Element element in filteredElementCollector) + { + Wire wire = (Wire)element; + int num = 2; + List list = new List(); + if (wire.WiringType == (WiringType)1) + { + for (int i = 0; i < wire.NumberOfVertices; i++) + { + XYZ vertex = wire.GetVertex(i); + list.Add(PostFixBase._pointFromFeetToMM(vertex)); + } + } + else + { + if (wire.WiringType != null) + { + throw new NotImplementedException(); + } + int num2 = wire.NumberOfVertices - 1; + double num3 = 0.33333333333333331 / (double)num2; + for (double num4 = 0.0; num4 < 1.0 + num3 / 10.0; num4 += num3) + { + double[] array = new double[3]; + for (int j = 0; j <= num2; j++) + { + XYZ vertex2 = wire.GetVertex(j); + double num5 = (double)Comb.nCr(num2, j); + double num6 = 1.0; + double num7 = 1.0; + if (j != num2) + { + num6 = Math.Pow(1.0 - num4, (double)(num2 - j)); + } + if (j != 0) + { + num7 = Math.Pow(num4, (double)j); + } + double num8 = num5 * num6 * num7; + array[0] += num8 * vertex2.X; + array[1] += num8 * vertex2.Y; + array[2] += num8 * vertex2.Z; + } + list.Add(PostFixBase._pointFromFeetToMM(new XYZ(array[0], array[1], array[2]))); + } + } + List list2 = new List(); + foreach (int[] array2 in list) + { + list2.Add(this.model.Create.CreateIfcCartesianPoint(new double[] + { + (double)array2[0], + (double)array2[1], + (double)array2[2] + })); + } + IfcPolyline ifcPolyline = this.model.Create.CreateIfcPolyline(list2); + IfcSweptDiskSolid ifcSweptDiskSolid = this.model.Create.CreateIfcSweptDiskSolid(ifcPolyline, (double)num, null, new double?(0.0), new double?((double)(list2.Count - 1))); + List list3 = new List { ifcSweptDiskSolid }; + IfcShapeRepresentation ifcShapeRepresentation = this.model.Create.CreateIfcShapeRepresentation(this.context_body, "Body", "SweptSolid", list3); + IfcProductDefinitionShape ifcProductDefinitionShape = this.model.Create.CreateIfcProductDefinitionShape(null, null, new List { ifcShapeRepresentation }); + IIfcFlowSegment ifcFlowSegment = this._createWireSegment(wire, ifcProductDefinitionShape); + ElementId typeId = wire.GetTypeId(); + if (!dictionary.ContainsKey(typeId.IntegerValue)) + { + Element element2 = this.doc.GetElement(typeId); + string text = element2.IfcGUID(); + List list4 = this._makeInternalRevitPsets(element2); + IfcCableSegmentType ifcCableSegmentType = this.model.Create.CreateIfcCableSegmentType(text, this.ownerHistory, element2.Name, null, null, list4, null, typeId.ToString(), null, IfcCableSegmentTypeEnum.CABLESEGMENT); + dictionary[typeId.IntegerValue] = ifcCableSegmentType; + dictionary2[typeId.IntegerValue] = new List(); + } + dictionary2[typeId.IntegerValue].Add(ifcFlowSegment as IfcObject); + foreach (IfcPropertySetDefinition ifcPropertySetDefinition in this._makeInternalRevitPsets(wire)) + { + this._createIfcRelDefinesByProperties(ifcFlowSegment as IfcObject, ifcPropertySetDefinition); + } + base.CreateClassification(wire, ifcFlowSegment as IfcObject); + } + foreach (int num9 in dictionary2.Keys) + { + IfcElementType ifcElementType = dictionary[num9]; + List list5 = dictionary2[num9].ToList(); + list5.Sort((IfcObject x, IfcObject y) => x.GlobalId.CompareTo(y.GlobalId)); + this.model.Create.CreateIfcRelDefinesByType(PostFixBase._createConstIfcGuid(ifcElementType.GlobalId + " RelToInsts"), this.ownerHistory, null, null, list5, ifcElementType); + } + } + + // Token: 0x060000D2 RID: 210 RVA: 0x0000A490 File Offset: 0x00008690 + private List _makeInternalRevitPsets(Element whichElement) + { + List list = new List(); + Dictionary> dictionary = new Dictionary>(); + ElementId id = whichElement.Id; + foreach (KeyValuePair keyValuePair in this._getNonIFCParametersForElement(whichElement)) + { + string text = LabelUtils.GetLabelFor(keyValuePair.Key); + if (whichElement is ElementType) + { + text += "(Type)"; + } + HashSet hashSet = new HashSet(); + dictionary[text] = hashSet; + foreach (Parameter parameter in keyValuePair.Value.ParameterCache.Values) + { + if (parameter.HasValue) + { + Definition definition = parameter.Definition; + if (definition != null) + { + string name = definition.Name; + switch (parameter.StorageType) + { + case (StorageType)1: + { + int num = parameter.AsInteger(); + string text2 = parameter.AsValueString(); + if (definition.ParameterType == (ParameterType)10) + { + hashSet.Add(this._createBooleanProperty(name, num != 0)); + } + else if (definition.ParameterType == null && text2 != null) + { + hashSet.Add(this._createIdentifierProperty(name, text2)); + } + else + { + hashSet.Add(this._createIntegerProperty(name, num)); + } + break; + } + case (StorageType)2: + { + double num2 = parameter.AsDouble(); + ParameterType parameterType = definition.ParameterType; + IfcProperty ifcProperty; + switch (parameterType) + { + case (ParameterType)4: + goto IL_0370; + case (ParameterType)5: + goto IL_0356; + case (ParameterType)6: + goto IL_063B; + case (ParameterType)7: + ifcProperty = this._createPlaneAngleMeasureProperty(name, UnitUtil.ScaleAngle(num2)); + break; + case (ParameterType)8: + case (ParameterType)9: + case (ParameterType)10: + goto IL_0652; + case (ParameterType)11: + { + double num3 = UnitUtil.ScaleForce(num2); + ifcProperty = this._createForceProperty(name, num3); + break; + } + default: + switch (parameterType) + { + case (ParameterType)109: + { + double num4 = UnitUtil.ScaleDouble((UnitType)9, num2); + IfcValue ifcValue = this._createDoubleMeasure(num4, "IfcReal"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue, "FRICTIONLOSS"); + break; + } + case (ParameterType)110: + case (ParameterType)118: + case (ParameterType)124: + case (ParameterType)134: + case (ParameterType)160: + case (ParameterType)163: + case (ParameterType)174: + { + double num5 = UnitUtil.ScalePower(num2); + ifcProperty = this._createPowerProperty(name, num5); + break; + } + case (ParameterType)111: + case (ParameterType)126: + case (ParameterType)127: + case (ParameterType)128: + case (ParameterType)129: + case (ParameterType)130: + case (ParameterType)131: + case (ParameterType)132: + case (ParameterType)133: + case (ParameterType)135: + case (ParameterType)136: + case (ParameterType)138: + case (ParameterType)142: + case (ParameterType)146: + case (ParameterType)147: + case (ParameterType)148: + case (ParameterType)149: + case (ParameterType)150: + case (ParameterType)151: + case (ParameterType)152: + case (ParameterType)153: + case (ParameterType)154: + case (ParameterType)156: + case (ParameterType)157: + case (ParameterType)158: + case (ParameterType)159: + case (ParameterType)161: + case (ParameterType)162: + case (ParameterType)164: + case (ParameterType)165: + case (ParameterType)166: + case (ParameterType)167: + case (ParameterType)168: + case (ParameterType)170: + case (ParameterType)171: + case (ParameterType)176: + case (ParameterType)178: + case (ParameterType)179: + case (ParameterType)180: + case (ParameterType)186: + case (ParameterType)190: + case (ParameterType)191: + case (ParameterType)192: + case (ParameterType)196: + case (ParameterType)197: + case (ParameterType)199: + case (ParameterType)202: + case (ParameterType)203: + case (ParameterType)205: + case (ParameterType)208: + goto IL_0652; + case (ParameterType)112: + case (ParameterType)139: + case (ParameterType)145: + { + double num6 = UnitUtil.ScaleDouble((UnitType)12, num2); + IfcValue ifcValue2 = this._createDoubleMeasure(num6, "IfcPressureMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue2, null); + break; + } + case (ParameterType)113: + case (ParameterType)140: + case (ParameterType)181: + { + double num7 = UnitUtil.ScaleDouble((UnitType)13, num2); + IfcValue ifcValue3 = this._createDoubleMeasure(num7, "IfcThermalTransmittanceMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue3, null); + break; + } + case (ParameterType)114: + case (ParameterType)141: + { + double num8 = UnitUtil.ScaleDouble((UnitType)14, num2); + IfcValue ifcValue4 = this._createDoubleMeasure(num8, "IfcLinearVelocityMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue4, null); + break; + } + case (ParameterType)115: + case (ParameterType)137: + { + double num9 = UnitUtil.ScaleVolumetricFlowRate(num2); + ifcProperty = this._createVolumetricFlowRateMeasureProperty(name, num9); + break; + } + case (ParameterType)116: + case (ParameterType)125: + case (ParameterType)143: + case (ParameterType)144: + case (ParameterType)169: + case (ParameterType)182: + case (ParameterType)183: + case (ParameterType)185: + case (ParameterType)187: + case (ParameterType)188: + case (ParameterType)189: + case (ParameterType)193: + case (ParameterType)194: + case (ParameterType)195: + case (ParameterType)201: + case (ParameterType)206: + case (ParameterType)207: + case (ParameterType)210: + case (ParameterType)212: + goto IL_0370; + case (ParameterType)117: + case (ParameterType)204: + case (ParameterType)209: + goto IL_0356; + case (ParameterType)119: + { + double num10 = UnitUtil.ScaleElectricCurrent(num2); + ifcProperty = this._createElectricCurrentMeasureProperty(name, num10); + break; + } + case (ParameterType)120: + { + double num11 = UnitUtil.ScaleElectricVoltage(num2); + ifcProperty = this._createElectricVoltageMeasureProperty(name, num11); + break; + } + case (ParameterType)121: + ifcProperty = this._createFrequencyProperty(name, num2); + break; + case (ParameterType)122: + { + double num12 = UnitUtil.ScaleIlluminance(num2); + ifcProperty = this._createIlluminanceProperty(name, num12); + break; + } + case (ParameterType)123: + { + double num13 = UnitUtil.ScaleLuminousFlux(num2); + ifcProperty = this._createLuminousFluxMeasureProperty(name, num13); + break; + } + case (ParameterType)155: + case (ParameterType)184: + case (ParameterType)211: + goto IL_063B; + case (ParameterType)172: + { + IfcValue ifcValue5 = (this.doubleIfcValues.ContainsKey("IFCMONETARYMEASURE") ? this._createDoubleMeasure(num2, "IfcMonetaryMeasure") : this._createDoubleMeasure(num2, "IfcReal")); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue5, null); + break; + } + case (ParameterType)173: + { + double num14 = UnitUtil.ScaleDouble((UnitType)73, num2); + IfcValue ifcValue6 = this._createDoubleMeasure(num14, "IfcReal"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue6, "LUMINOUSEFFICACY"); + break; + } + case (ParameterType)175: + { + double num15 = UnitUtil.ScaleDouble((UnitType)75, num2); + IfcValue ifcValue7 = this._createDoubleMeasure(num15, "IfcReal"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue7, "COLORTEMPERATURE"); + break; + } + case (ParameterType)177: + { + double num16 = UnitUtil.ScaleLuminousIntensity(num2); + ifcProperty = this._createLuminousIntensityProperty(name, num16); + break; + } + case (ParameterType)198: + { + double num17 = UnitUtil.ScaleDouble((UnitType)98, num2); + IfcValue ifcValue8 = this._createDoubleMeasure(num17, "IfcMassMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue8, null); + break; + } + case (ParameterType)200: + { + double num18 = UnitUtil.ScaleDouble((UnitType)100, num2); + IfcValue ifcValue9 = this._createDoubleMeasure(num18, "IfcMomentofInertiaMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue9, null); + break; + } + default: + { + if (parameterType != (ParameterType)222) + { + goto IL_0652; + } + double num19 = UnitUtil.ScaleDouble((UnitType)122, num2); + IfcValue ifcValue10 = this._createDoubleMeasure(num19, "IfcMassDensityMeasure"); + ifcProperty = this._createCommonPropertySingleValue(name, ifcValue10, null); + break; + } + } + break; + } + IL_0677: + if (ifcProperty != null) + { + hashSet.Add(ifcProperty); + break; + } + break; + IL_0370: + ifcProperty = this._createLengthMeasureProperty(name, UnitUtil.ScaleLength(num2)); + goto IL_0677; + IL_0356: + double num20 = UnitUtil.ScaleArea(num2); + ifcProperty = this._createAreaMeasureProperty(name, num20); + goto IL_0677; + IL_063B: + double num21 = UnitUtil.ScaleVolume(num2); + ifcProperty = this._createVolumeMeasureProperty(name, num21); + goto IL_0677; + IL_0652: + double num22 = num2; + try + { + num22 = UnitUtils.ConvertFromInternalUnits(num2, PostFixBase._getUnitTypeId(parameter)); + } + catch + { + } + ifcProperty = this._createRealProperty(name, num22); + goto IL_0677; + } + case (StorageType)3: + { + string text3 = parameter.AsString(); + hashSet.Add(this._createTextProperty(name, text3)); + break; + } + case (StorageType)4: + if (!(parameter.AsElementId() == ElementId.InvalidElementId)) + { + string text4 = base._elementIdParameterAsString(parameter); + hashSet.Add(this._createLabelProperty(name, text4)); + } + break; + } + } + } + } + } + foreach (string text5 in dictionary.Keys) + { + List list2 = dictionary[text5].Where((IfcProperty t) => t != null).ToList(); + if (list2.Any()) + { + IfcPropertySet ifcPropertySet = this.model.Create.CreateIfcPropertySet(PostFixBase._createConstIfcGuid("Pset " + text5 + " of " + whichElement.IfcGUID()), this.ownerHistory, text5, null, list2); + list.Add(ifcPropertySet); + } + } + return list; + } + + // Token: 0x060000D3 RID: 211 RVA: 0x0000ACBC File Offset: 0x00008EBC + private IfcValue _createDoubleMeasure(double value, string measureName) + { + string text = measureName.ToUpperInvariant(); + if (this.doubleIfcValues.ContainsKey(text)) + { + return this.doubleIfcValues[text].Invoke(null, new object[] { value }) as IfcValue; + } + return null; + } + + // Token: 0x060000D4 RID: 212 RVA: 0x0000AD08 File Offset: 0x00008F08 + private IfcValue _createStringMeasure(string value, string measureName) + { + string text = measureName.ToUpperInvariant(); + if (this.stringIfcValues.ContainsKey(text)) + { + return this.stringIfcValues[text].Invoke(null, new object[] { value }) as IfcValue; + } + return null; + } + + // Token: 0x060000D5 RID: 213 RVA: 0x0000AD4D File Offset: 0x00008F4D + private IfcPropertySingleValue _createCommonPropertySingleValue(string parameterCaption, IfcValue nominalValue, string unitKey) + { + if (nominalValue == null) + { + return null; + } + return this.model.Create.CreateIfcPropertySingleValue(parameterCaption, null, nominalValue, null); + } + + // Token: 0x060000D6 RID: 214 RVA: 0x0000AD68 File Offset: 0x00008F68 + private IfcProperty _createForceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcForceMeasure(scaledValue), null); + } + + // Token: 0x060000D7 RID: 215 RVA: 0x0000AD78 File Offset: 0x00008F78 + private IfcProperty _createElectricCurrentMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcElectricCurrentMeasure(scaledValue), null); + } + + // Token: 0x060000D8 RID: 216 RVA: 0x0000AD88 File Offset: 0x00008F88 + private IfcProperty _createFrequencyProperty(string parameterCaption, double value) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcFrequencyMeasure(value), null); + } + + // Token: 0x060000D9 RID: 217 RVA: 0x0000AD98 File Offset: 0x00008F98 + private IfcProperty _createElectricVoltageMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcElectricVoltageMeasure(scaledValue), null); + } + + // Token: 0x060000DA RID: 218 RVA: 0x0000ADA8 File Offset: 0x00008FA8 + private IfcProperty _createLuminousIntensityProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLuminousIntensityMeasure(scaledValue), null); + } + + // Token: 0x060000DB RID: 219 RVA: 0x0000ADB8 File Offset: 0x00008FB8 + private IfcProperty _createPlanarForceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcPlanarForceMeasure(scaledValue), null); + } + + // Token: 0x060000DC RID: 220 RVA: 0x0000ADC8 File Offset: 0x00008FC8 + private IfcProperty _createLinearForceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLinearForceMeasure(scaledValue), null); + } + + // Token: 0x060000DD RID: 221 RVA: 0x0000ADD8 File Offset: 0x00008FD8 + private IfcProperty _createVolumetricFlowRateMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcVolumetricFlowRateMeasure(scaledValue), null); + } + + // Token: 0x060000DE RID: 222 RVA: 0x0000ADE8 File Offset: 0x00008FE8 + private IfcProperty _createVolumeMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcVolumeMeasure(scaledValue), null); + } + + // Token: 0x060000DF RID: 223 RVA: 0x0000ADF8 File Offset: 0x00008FF8 + private IfcProperty _createRealProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcReal(scaledValue), null); + } + + // Token: 0x060000E0 RID: 224 RVA: 0x0000AE08 File Offset: 0x00009008 + private IfcProperty _createLuminousFluxMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLuminousFluxMeasure(scaledValue), null); + } + + // Token: 0x060000E1 RID: 225 RVA: 0x0000AE18 File Offset: 0x00009018 + private IfcProperty _createIlluminanceProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcIlluminanceMeasure(scaledValue), null); + } + + // Token: 0x060000E2 RID: 226 RVA: 0x0000AE28 File Offset: 0x00009028 + private IfcProperty _createAreaMeasureProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcAreaMeasure(scaledValue), null); + } + + // Token: 0x060000E3 RID: 227 RVA: 0x0000AE38 File Offset: 0x00009038 + private IfcProperty _createLengthMeasureProperty(string parameterCaption, double v) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLengthMeasure(v), null); + } + + // Token: 0x060000E4 RID: 228 RVA: 0x0000AE48 File Offset: 0x00009048 + private IfcProperty _createPowerProperty(string parameterCaption, double scaledValue) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcPowerMeasure(scaledValue), null); + } + + // Token: 0x060000E5 RID: 229 RVA: 0x0000AE58 File Offset: 0x00009058 + private IfcProperty _createPlaneAngleMeasureProperty(string parameterCaption, double v) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcPlaneAngleMeasure(v), null); + } + + // Token: 0x060000E6 RID: 230 RVA: 0x0000AE68 File Offset: 0x00009068 + private IfcProperty _createIntegerProperty(string parameterCaption, int value) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcInteger(value), null); + } + + // Token: 0x060000E7 RID: 231 RVA: 0x0000AE78 File Offset: 0x00009078 + private IfcProperty _createIdentifierProperty(string parameterCaption, string valueAsString) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcIdentifier(valueAsString), null); + } + + // Token: 0x060000E8 RID: 232 RVA: 0x0000AE88 File Offset: 0x00009088 + private IfcProperty _createLabelProperty(string parameterCaption, string valueString) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcLabel(valueString), null); + } + + // Token: 0x060000E9 RID: 233 RVA: 0x0000AE98 File Offset: 0x00009098 + private IfcProperty _createTextProperty(string parameterCaption, string value) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcText(value), null); + } + + // Token: 0x060000EA RID: 234 RVA: 0x0000AEA8 File Offset: 0x000090A8 + private IfcProperty _createBooleanProperty(string parameterCaption, bool v) + { + return this._createCommonPropertySingleValue(parameterCaption, IfcValue.SetIfcBoolean(v), null); + } + + // Token: 0x060000EB RID: 235 RVA: 0x0000AEB8 File Offset: 0x000090B8 + private IDictionary _getNonIFCParametersForElement(Element element) + { + IDictionary dictionary = new Dictionary(); + ParameterSet parameters = element.Parameters; + if (parameters.Size == 0) + { + return dictionary; + } + IDictionary> dictionary2 = new SortedDictionary>(); + ParameterSetIterator parameterSetIterator = parameters.ForwardIterator(); + while (parameterSetIterator.MoveNext()) + { + object obj = parameterSetIterator.Current; + Parameter parameter = obj as Parameter; + if (parameter != null && !PostFix_IFC4._isDuplicateParameter(parameter)) + { + Definition definition = parameter.Definition; + if (definition != null) + { + InternalDefinition internalDefinition = definition as InternalDefinition; + if (internalDefinition == null || internalDefinition.Visible) + { + string name = definition.Name; + if (!string.IsNullOrWhiteSpace(name)) + { + dictionary2[parameter.Id.IntegerValue] = new KeyValuePair(name, parameter); + } + } + } + } + } + foreach (KeyValuePair keyValuePair in dictionary2.Values) + { + Parameter value = keyValuePair.Value; + Definition definition2 = value.Definition; + string key = keyValuePair.Key; + BuiltInParameterGroup parameterGroup = definition2.ParameterGroup; + ParameterElementCache parameterElementCache = null; + if (parameterGroup != (BuiltInParameterGroup)(-5000131)) + { + if (!dictionary.TryGetValue(parameterGroup, out parameterElementCache)) + { + parameterElementCache = new ParameterElementCache(); + dictionary[parameterGroup] = parameterElementCache; + } + } + else if (!dictionary.TryGetValue(parameterGroup, out parameterElementCache)) + { + parameterElementCache = new ParameterElementCache(); + dictionary[parameterGroup] = parameterElementCache; + } + if (parameterElementCache != null && (!parameterElementCache.ParameterCache.ContainsKey(key) || !parameterElementCache.ParameterCache[key].HasValue)) + { + parameterElementCache.ParameterCache[key] = value; + } + } + return dictionary; + } + + // Token: 0x060000EC RID: 236 RVA: 0x0000B044 File Offset: 0x00009244 + private static bool _isDuplicateParameter(Parameter parameter) + { + return parameter.Id.IntegerValue == -1140363 || parameter.Id.IntegerValue == -1001125; + } + + // Token: 0x060000ED RID: 237 RVA: 0x0000B070 File Offset: 0x00009270 + protected override IIfcFlowSegment _createWireSegment(Wire wire, IIfcProductDefinitionShape defShape) + { + string text = wire.IfcGUID(); + string text2 = base._getRevitName(wire); + string text3 = wire.Id.IntegerValue.ToString(); + ElementId typeId = wire.GetTypeId(); + Element element = wire.Document.GetElement(typeId); + string text4 = null; + if (element != null) + { + text4 = element.Name; + } + return this.model.Create.CreateIfcCableSegment(text, this.ownerHistory, text2, null, text4, null, defShape as IfcProductDefinitionShape, text3, IfcCableSegmentTypeEnum.CABLESEGMENT); + } + + // Token: 0x060000EE RID: 238 RVA: 0x0000B0F0 File Offset: 0x000092F0 + protected override IIfcRelDefinesByProperties _createIfcRelDefinesByProperties(IIfcObject obj, IIfcPropertySetDefinition pset) + { + string text = PostFixBase._createConstIfcGuid(obj.GlobalId + " RelToPset " + pset.Name); + return this.model.Create.CreateIfcRelDefinesByProperties(text, this.ownerHistory, null, null, new List { obj as IfcObjectDefinition }, pset as IfcPropertySetDefinition); + } + + // Token: 0x060000EF RID: 239 RVA: 0x0000B150 File Offset: 0x00009350 + protected override IIfcClassification _createClassification(string classificationSource, string classificationEdition, string classificationName, int day, int month, int year) + { + string text = null; + if (day > 0 && month > 0 && year > 0) + { + DateTime dateTime = new DateTime(year, month, day); + text = dateTime.ToString("yyyy-MM-dd"); + } + return this.model.Create.CreateIfcClassification(classificationSource, classificationEdition, text, classificationName, null, null, null); + } + + // Token: 0x060000F0 RID: 240 RVA: 0x0000B1A0 File Offset: 0x000093A0 + protected override IIfcClassificationReference _createClassificationReference(IIfcClassification classification, string classificationCode, string classificationDescription, string location) + { + IfcClassification ifcClassification = classification as IfcClassification; + if (!string.IsNullOrEmpty(location)) + { + ifcClassification.Location = location; + } + return this.model.Create.CreateIfcClassificationReference(location, classificationCode, classificationDescription, ifcClassification, null, null); + } + + // Token: 0x060000F1 RID: 241 RVA: 0x0000B1E4 File Offset: 0x000093E4 + protected override IIfcRelAssociatesClassification _createRelAssociatesClassification(string key, List entsList, IIfcClassificationReference reference) + { + string text = PostFixBase._createConstIfcGuid("relAssoClass for " + key); + List list = new List(); + foreach (IIfcObjectDefinition ifcObjectDefinition in entsList) + { + list.Add(ifcObjectDefinition as IfcObjectDefinition); + } + int num = key.IndexOf(':'); + string text2 = key.Substring(0, num) + " Classification"; + return this.model.Create.CreateIfcRelAssociatesClassification(text, this.ownerHistory, text2, null, list, reference as IfcClassificationReference); + } + + // Token: 0x040000A4 RID: 164 + private IfcGeometricRepresentationContext context_body; + + // Token: 0x040000A5 RID: 165 + private IfcOwnerHistory ownerHistory; + + // Token: 0x040000A6 RID: 166 + private Dictionary doubleIfcValues = new Dictionary(); + + // Token: 0x040000A7 RID: 167 + private Dictionary stringIfcValues = new Dictionary(); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/SubModelExtractor.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/SubModelExtractor.cs new file mode 100644 index 0000000..f25320d --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/SubModelExtractor.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.MVD; +using CBIMS.MVD.InterIfc; +using CBIMS.MVDLite.Checker; +using CBIMS.STEParser; +using CBIMS.STEParser.EB; + +namespace IFC_Revit_Interop.NetCore +{ + // Token: 0x02000022 RID: 34 + public static class SubModelExtractor + { + // Token: 0x06000093 RID: 147 RVA: 0x00007C3C File Offset: 0x00005E3C + public static void MVDRootedExtractor(ISTEPModel modelIn, List rootIds, string outModelPath) + { + IModel model = ModelLoader.Load(modelIn); + IMvdTypeHelper mvdTypeHelper = new InterIfcTypeHelper(model.SchemaVersion, model); + STEPModel stepmodel = new STEPModel(); + stepmodel.Header = modelIn.Header; + MVDLiteRootedExtractor mvdliteRootedExtractor = new MVDLiteRootedExtractor(MVDLiteRootedExtractor.RootReduceMode.IFCELEMENT, mvdTypeHelper, false, false, null); + mvdliteRootedExtractor.logger = new MVDConsoleLogger(); + mvdliteRootedExtractor.InitRoot(rootIds); + string text = SubModelExtractor.QUERY_ABBRS_IFC4; + if (model.SchemaVersion == IfcSchemaVersion.IFC2X3) + { + text = SubModelExtractor.QUERY_ABBRS_IFC2X3; + } + mvdliteRootedExtractor.InitWithString(text); + mvdliteRootedExtractor.InitWithString(SubModelExtractor.STRING_FOR_EXTRACT); + Dictionary dictionary = new Dictionary(); + mvdliteRootedExtractor.Extract(modelIn, stepmodel, dictionary); + stepmodel.Write(outModelPath); + } + + // Token: 0x04000093 RID: 147 + private static string QUERY_ABBRS_IFC4 = "类型 as (IfcObject)->IsTypedBy:IfcRelDefinesByType->RelatingType:IfcTypeObject\n实例属性集 as (IfcObject)->IsDefinedBy:IfcRelDefinesByProperties->RelatingPropertyDefinition:IfcPropertySet\n类型属性集 as (IfcObject)->类型->HasPropertySets:IfcPropertySet\n任意属性集 as (IfcObject)(->实例属性集 或 ->类型属性集)\n单值属性 as (IfcPropertySet)->HasProperties:IfcPropertySingleValue\n任意属性 as (IfcPropertySet)->HasProperties\n单值 as (IfcPropertySingleValue)->NominalValue:IfcValue\n简单几何表达 as (IfcProduct)->Representation:IfcProductDefinitionShape->Representations:IfcShapeRepresentation\n映射几何表达 as (IfcProduct)->简单几何表达->Items:IfcMappedItem->MappingSource:IfcRepresentationMap->MappedRepresentation:IfcShapeRepresentation\n类型几何表达 as (IfcProduct)->类型->RepresentationMaps->MappedRepresentation:IfcShapeRepresentation\n组装几何表达 as (IfcProduct)->IsDecomposedBy->RelatedObjects(->简单几何表达 OR ->映射几何表达)\n几何表达 as (IfcProduct)(->简单几何表达 OR ->映射几何表达 OR ->类型几何表达 OR ->组装几何表达)\n开口几何 as (IfcElement)->HasOpenings->RelatedOpeningElement->几何表达\n表面几何 as (IfcElement)->HasCoverings:IfcCovering->几何表达\n布尔几何表达项 as (IfcProduct)->简单几何表达->Items:IfcBooleanResult(->FirstOperand:IfcBooleanOperand OR ->SecondOperand:IfcBooleanOperand)\n布尔几何表达项嵌套1层 as (IfcProduct)->布尔几何表达项(->FirstOperand:IfcBooleanOperand OR ->SecondOperand:IfcBooleanOperand)\n几何表达项 as (IfcShapeRepresentation)->Items:IfcRepresentationItem\n几何样式 as (IfcRepresentationItem)->StyledByItem:IfcStyledItem\n直接表面样式 as (IfcStyledItem)->Styles:IfcSurfaceStyle\n间接表面样式 as (IfcStyledItem)->Styles:IfcPresentationStyleAssignment->Styles:IfcSurfaceStyle\n表面颜色 as (IfcSurfaceStyle)->Styles:IfcSurfaceStyleRendering->SurfaceColour:IfcColourRgb\n几何颜色 as (IfcElement)((->几何表达 OR ->表面几何 OR ->组装几何)->几何表达项 OR ->布尔几何表达项 OR ->布尔几何表达项嵌套1层)->几何样式(->直接表面样式 OR ->间接表面样式)->表面颜色\n"; + + // Token: 0x04000094 RID: 148 + private static string QUERY_ABBRS_IFC2X3 = "类型 as (IfcObject)->IsDefinedBy:IfcRelDefinesByType->RelatingType:IfcTypeObject\n实例属性集 as (IfcObject)->IsDefinedBy:IfcRelDefinesByProperties->RelatingPropertyDefinition:IfcPropertySet\n类型属性集 as (IfcObject)->类型->HasPropertySets:IfcPropertySet\n任意属性集 as (IfcObject)(->实例属性集 或 ->类型属性集)\n单值属性 as (IfcPropertySet)->HasProperties:IfcPropertySingleValue\n任意属性 as (IfcPropertySet)->HasProperties\n单值 as (IfcPropertySingleValue)->NominalValue:IfcValue\n简单几何表达 as (IfcProduct)->Representation:IfcProductDefinitionShape->Representations:IfcShapeRepresentation\n映射几何表达 as (IfcProduct)->简单几何表达->Items:IfcMappedItem->MappingSource:IfcRepresentationMap->MappedRepresentation:IfcShapeRepresentation\n类型几何表达 as (IfcProduct)->类型->RepresentationMaps->MappedRepresentation:IfcShapeRepresentation\n组装几何表达 as (IfcProduct)->IsDecomposedBy->RelatedObjects(->简单几何表达 OR ->映射几何表达)\n几何表达 as (IfcProduct)(->简单几何表达 OR ->映射几何表达 OR ->类型几何表达 OR ->组装几何表达)\n开口几何 as (IfcElement)->HasOpenings->RelatedOpeningElement->几何表达\n表面几何 as (IfcElement)->HasCoverings:IfcCovering->几何表达\n布尔几何表达项 as (IfcProduct)->简单几何表达->Items:IfcBooleanResult(->FirstOperand:IfcBooleanOperand OR ->SecondOperand:IfcBooleanOperand)\n布尔几何表达项嵌套1层 as (IfcProduct)->布尔几何表达项(->FirstOperand:IfcBooleanOperand OR ->SecondOperand:IfcBooleanOperand)\n几何表达项 as (IfcShapeRepresentation)->Items:IfcRepresentationItem\n几何样式 as (IfcRepresentationItem)->StyledByItem:IfcStyledItem\n间接表面样式 as (IfcStyledItem)->Styles:IfcPresentationStyleAssignment->Styles:IfcSurfaceStyle\n表面颜色 as (IfcSurfaceStyle)->Styles:IfcSurfaceStyleRendering->SurfaceColour:IfcColourRgb\n几何颜色 as (IfcElement)((->几何表达 OR ->表面几何)->几何表达项 OR ->布尔几何表达项 OR ->布尔几何表达项嵌套1层)->几何样式->间接表面样式->表面颜色\n"; + + // Token: 0x04000095 RID: 149 + private static string STRING_FOR_EXTRACT = "约束\n//保留几何、开口与颜色的附加语句\nIfcElement->几何表达[Exists]=TRUE\nIfcElement->表面几何[Exists]=TRUE\nIfcElement->开口几何[Exists]=TRUE\nIfcElement->几何颜色[Exists]=TRUE\n//保留空间结构的附加语句\nIfcElement->ContainedInStructure[Exists]=TRUE\nIfcProject->IsDecomposedBy[Exists]=TRUE\nIfcSite->IsDecomposedBy[Exists]=TRUE\nIfcBuilding->IsDecomposedBy[Exists]=TRUE\nIfcBuildingStorey->IsDecomposedBy[Exists]=TRUE\n//保留所有属性的附加语句\nIfcObject->任意属性集->任意属性[Exists]=TRUE\n"; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/TrimClassification.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/TrimClassification.cs new file mode 100644 index 0000000..1caead5 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/NetCore/TrimClassification.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CBIMS.InterIFC.IFC; +using CBIMS.InterIFC.STEP; +using CBIMS.STEParser.EB.IFC2X3; +using CBIMS.STEParser.EB.IFC4; +using CBIMS.STEParser.EB.IFC4X1; +using CBIMS.STEParser.EB.IFC4X2; + +namespace IFC_Revit_Interop.NetCore +{ + // Token: 0x02000023 RID: 35 + public static class TrimClassification + { + // Token: 0x06000095 RID: 149 RVA: 0x00007CEC File Offset: 0x00005EEC + public static void TrimClassificationInModel(ISTEPModel stepModel) + { + IModel model = null; + string text = stepModel.SchemaVersion.ElementAt(0); + if (!(text == "IFC2X3")) + { + if (!(text == "IFC4")) + { + if (!(text == "IFC4X1")) + { + if (!(text == "IFC4X2")) + { + throw new Exception("不支持的IFC 版本"); + } + model = new CBIMS.STEParser.EB.IFC4X2.Model(stepModel); + } + else + { + model = new CBIMS.STEParser.EB.IFC4X1.Model(stepModel); + } + } + else + { + model = new CBIMS.STEParser.EB.IFC4.Model(stepModel); + } + } + else + { + model = new CBIMS.STEParser.EB.IFC2X3.Model(stepModel); + } + if (model == null) + { + return; + } + Dictionary dictionary = new Dictionary(); + Dictionary> dictionary2 = new Dictionary>(); + foreach (IIfcRelAssociatesClassification ifcRelAssociatesClassification in model.FindAll(true)) + { + if (ifcRelAssociatesClassification.Name != null && ifcRelAssociatesClassification.Name.Equals("SZ-IFC Classification")) + { + IIfcClassificationReference ifcClassificationReference = null; + IIfcElement ifcElement = null; + if (ifcRelAssociatesClassification.RelatingClassification != null) + { + OneOf relatingClassification = ifcRelAssociatesClassification.RelatingClassification; + if (relatingClassification.IsT1) + { + IIfcClassificationNotationSelect asT = relatingClassification.AsT1; + if (asT.Type == IIfcClassificationNotationSelectType.IFCCLASSIFICATIONREFERENCE) + { + ifcClassificationReference = asT.AsIfcClassificationReference(); + } + } + else if (relatingClassification.IsT2) + { + IIfcClassificationSelect asT2 = relatingClassification.AsT2; + if (asT2.Type == IIfcClassificationSelectType.IFCCLASSIFICATIONREFERENCE) + { + ifcClassificationReference = asT2.AsIfcClassificationReference(); + } + } + } + if (ifcRelAssociatesClassification.RelatedObjects != null) + { + OneOf, IList> relatedObjects = ifcRelAssociatesClassification.RelatedObjects; + if (relatedObjects.IsT1) + { + IList asT3 = relatedObjects.AsT1; + if (asT3.Count == 1 && asT3.FirstOrDefault().Type == IIfcDefinitionSelectType.IFCOBJECTDEFINITION) + { + IIfcObjectDefinition ifcObjectDefinition = asT3.FirstOrDefault().AsIfcObjectDefinition(); + if (ifcObjectDefinition is IIfcElement) + { + ifcElement = ifcObjectDefinition as IIfcElement; + } + } + } + if (relatedObjects.IsT2) + { + IList asT4 = relatedObjects.AsT2; + if (asT4.Count == 1 && asT4.FirstOrDefault() is IIfcElement) + { + ifcElement = asT4.FirstOrDefault() as IIfcElement; + } + } + } + if (ifcClassificationReference != null && ifcElement != null) + { + string identification = ifcClassificationReference.Identification; + if (!string.IsNullOrEmpty(identification)) + { + dictionary[ifcElement.IFC_Id] = identification; + dictionary2[ifcElement.IFC_Id] = new List { ifcRelAssociatesClassification.IFC_Id, ifcClassificationReference.IFC_Id }; + } + } + } + } + foreach (IIfcElement ifcElement2 in model.FindAll(true)) + { + if (ifcElement2.IsDecomposedBy != null && dictionary.ContainsKey(ifcElement2.IFC_Id)) + { + string text2 = dictionary[ifcElement2.IFC_Id]; + if (ifcElement2.IsDecomposedBy.IsT1) + { + using (IEnumerator enumerator3 = ifcElement2.IsDecomposedBy.AsT1.GetEnumerator()) + { + while (enumerator3.MoveNext()) + { + IIfcRelAggregates ifcRelAggregates = enumerator3.Current; + foreach (IIfcObjectDefinition ifcObjectDefinition2 in ifcRelAggregates.RelatedObjects) + { + if (dictionary.ContainsKey(ifcObjectDefinition2.IFC_Id) && dictionary[ifcObjectDefinition2.IFC_Id].Equals(text2)) + { + foreach (int num in dictionary2[ifcObjectDefinition2.IFC_Id]) + { + model.RemoveEntity(num); + } + } + } + } + continue; + } + } + if (ifcElement2.IsDecomposedBy.IsT2) + { + foreach (IIfcRelDecomposes ifcRelDecomposes in ifcElement2.IsDecomposedBy.AsT2) + { + foreach (IIfcObjectDefinition ifcObjectDefinition3 in ifcRelDecomposes.RelatedObjects) + { + if (dictionary.ContainsKey(ifcObjectDefinition3.IFC_Id) && dictionary[ifcObjectDefinition3.IFC_Id].Equals(text2)) + { + foreach (int num2 in dictionary2[ifcObjectDefinition3.IFC_Id]) + { + model.RemoveEntity(num2); + } + } + } + } + } + } + } + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ParentFinder.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ParentFinder.cs new file mode 100644 index 0000000..ead5eb6 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ParentFinder.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using Autodesk.Revit.DB; +using IFC_Revit_Interop.Utils; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000018 RID: 24 + internal class ParentFinder + { + // Token: 0x06000078 RID: 120 RVA: 0x00006E5C File Offset: 0x0000505C + public ParentFinder(Document doc, Log log) + { + this.log = log; + this.doc = doc; + this.coll = new FilteredElementCollector(doc).WhereElementIsNotElementType().WhereElementIsViewIndependent(); + } + + // Token: 0x06000079 RID: 121 RVA: 0x00006E93 File Offset: 0x00005093 + public void Find() + { + new CurtainParentFinder(this).Find(); + new RailingParentFinder(this).Find(); + } + + // Token: 0x04000078 RID: 120 + public Log log; + + // Token: 0x04000079 RID: 121 + public Document doc; + + // Token: 0x0400007A RID: 122 + public Dictionary ChildToParent = new Dictionary(); + + // Token: 0x0400007B RID: 123 + public FilteredElementCollector coll; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/RailingParentFinder.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/RailingParentFinder.cs new file mode 100644 index 0000000..2209870 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/RailingParentFinder.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Architecture; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200001A RID: 26 + internal class RailingParentFinder + { + // Token: 0x06000082 RID: 130 RVA: 0x00007270 File Offset: 0x00005470 + public RailingParentFinder(ParentFinder host) + { + this.host = host; + } + + // Token: 0x06000083 RID: 131 RVA: 0x00007280 File Offset: 0x00005480 + public void Find() + { + foreach (Element element3 in this.host.coll.Where((Element element) => element is ContinuousRail)) + { + try + { + ContinuousRail continuousRail = element3 as ContinuousRail; + if (continuousRail.HostRailingId != ElementId.InvalidElementId) + { + this.host.ChildToParent[continuousRail.Id.IntegerValue] = continuousRail.HostRailingId.IntegerValue; + } + } + catch (Exception ex) + { + this.host.log.WriteException("ERR_RailingParentFinder", ex); + } + } + foreach (Element element2 in this.host.coll.Where((Element element) => element is Railing)) + { + try + { + ICollection collection = RailingParentFinder.CollectSubElements(element2 as Railing); + if (collection != null) + { + foreach (ElementId elementId in collection) + { + this.host.ChildToParent[elementId.IntegerValue] = element2.Id.IntegerValue; + } + } + } + catch (Exception ex2) + { + this.host.log.WriteException("ERR_RailingParentFinder", ex2); + } + } + } + + // Token: 0x06000084 RID: 132 RVA: 0x00007450 File Offset: 0x00005650 + public static ICollection CollectSubElements(Railing railingElem) + { + IList list = new List(); + if (railingElem != null) + { + ElementId topRail = railingElem.TopRail; + if (topRail != ElementId.InvalidElementId) + { + list.Add(topRail); + } + IList handRails = railingElem.GetHandRails(); + if (handRails != null) + { + foreach (ElementId elementId in handRails) + { + HandRail handRail = railingElem.Document.GetElement(elementId) as HandRail; + if (handRail != null) + { + list.Add(elementId); + foreach (ElementId elementId2 in handRail.GetSupports()) + { + list.Add(elementId2); + } + } + } + } + } + return list; + } + + // Token: 0x0400007E RID: 126 + private ParentFinder host; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/RevitReportGenerator.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/RevitReportGenerator.cs new file mode 100644 index 0000000..beebd49 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/RevitReportGenerator.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using IFC_ExcelReport; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200001C RID: 28 + public class RevitReportGenerator : AbstractReportGenerator + { + // Token: 0x06000087 RID: 135 RVA: 0x00007600 File Offset: 0x00005800 + public RevitReportGenerator(Dictionary cateNameMap) + : base("RVT") + { + this.cateNameMap = cateNameMap; + } + + // Token: 0x06000088 RID: 136 RVA: 0x00007614 File Offset: 0x00005814 + protected override string GetSoftwareCateName(string softwareElemId) + { + if (this.cateNameMap.ContainsKey(softwareElemId)) + { + return this.cateNameMap[softwareElemId]; + } + return null; + } + + // Token: 0x04000080 RID: 128 + private Dictionary cateNameMap; + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Rvt2Obj.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Rvt2Obj.cs new file mode 100644 index 0000000..7629d75 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Rvt2Obj.cs @@ -0,0 +1,567 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Visual; +using IFC_Revit_Interop.Utils; +using Microsoft.Win32; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200000A RID: 10 + internal class Rvt2Obj : IExportContext + { + // Token: 0x0600002A RID: 42 RVA: 0x00003B30 File Offset: 0x00001D30 + public Rvt2Obj(Document doc, string objSavePath, string textureDir, int meshLod, Log log = null) + { + this.resultPath = objSavePath; + this.resultTexturePath = textureDir; + if (!Directory.Exists(this.resultTexturePath)) + { + Directory.CreateDirectory(this.resultTexturePath); + } + this.m_doc = doc; + this.m_TransformationStack.Push(Transform.Identity); + this._precision = meshLod; + this.log = log; + } + + // Token: 0x0600002B RID: 43 RVA: 0x00003BD4 File Offset: 0x00001DD4 + public bool Start() + { + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.resultPath); + this.swObj = new StreamWriter(Path.GetDirectoryName(this.resultPath) + "\\" + fileNameWithoutExtension + ".obj"); + this.swObj.Write("mtllib " + fileNameWithoutExtension + ".mtl\n"); + this.swMtl = new StreamWriter(Path.GetDirectoryName(this.resultPath) + "\\" + fileNameWithoutExtension + ".mtl"); + RegistryKey localMachine = Registry.LocalMachine; + RegistryKey registryKey = localMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Autodesk\\ADSKTextureLibrary\\1"); + if (registryKey != null && int.Parse("2018") < 2020) + { + this.textureLibraryPath = registryKey.GetValue("LibraryPaths").ToString(); + } + else + { + registryKey = localMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Autodesk\\ADSKTextureLibraryNew\\1"); + if (registryKey != null) + { + string[] subKeyNames = registryKey.GetSubKeyNames(); + if (subKeyNames.Length != 0) + { + registryKey = localMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Autodesk\\ADSKTextureLibraryNew\\1\\" + subKeyNames[0]); + } + if (registryKey != null) + { + this.textureLibraryPath = registryKey.GetValue("LibraryPaths").ToString(); + } + } + } + if (string.IsNullOrEmpty(this.textureLibraryPath)) + { + Log log = this.log; + if (log != null) + { + log.Write("Texture", "Revit Texture Library not found in Regedit."); + } + return false; + } + localMachine.Close(); + registryKey.Close(); + return true; + } + + // Token: 0x0600002C RID: 44 RVA: 0x00003D10 File Offset: 0x00001F10 + public RenderNodeAction OnViewBegin(ViewNode node) + { + node.LevelOfDetail = this._precision; + return 0; + } + + // Token: 0x0600002D RID: 45 RVA: 0x00003D1F File Offset: 0x00001F1F + public RenderNodeAction OnLinkBegin(LinkNode node) + { + return (RenderNodeAction)1; + } + + // Token: 0x0600002E RID: 46 RVA: 0x00003D24 File Offset: 0x00001F24 + public RenderNodeAction OnElementBegin(ElementId elementId) + { + this.currentId = elementId; + this.elementPolyIndex = 0; + this.productTris[this.currentId.IntegerValue] = 0; + Utils_SendMessage.UpdateProgressUI(5, 90, (double)this.currentElementCount * 1.0 / (double)this.totalElementCount); + this.currentElementCount++; + return 0; + } + + // Token: 0x0600002F RID: 47 RVA: 0x00003D88 File Offset: 0x00001F88 + private Material GetElementTypeMaterial(ElementId eleId) + { + ElementType elementType = this.m_doc.GetElement(eleId) as ElementType; + if (elementType == null) + { + return null; + } + foreach (Parameter parameter in elementType.GetOrderedParameters()) + { + if (parameter.StorageType == (StorageType)4) + { + Definition definition = parameter.Definition; + if (definition.ParameterGroup == (BuiltInParameterGroup)(-5000105) && definition.ParameterType == (ParameterType)9) + { + ElementId elementId = parameter.AsElementId(); + if (-1 != elementId.IntegerValue) + { + return this.m_doc.GetElement(elementId) as Material; + } + break; + } + } + } + return null; + } + + // Token: 0x06000030 RID: 48 RVA: 0x00003E38 File Offset: 0x00002038 + private string GetMaterialTexturePath(Material m) + { + if (m == null) + { + return null; + } + ElementId appearanceAssetId = m.AppearanceAssetId; + if (appearanceAssetId != ElementId.InvalidElementId) + { + AppearanceAssetElement appearanceAssetElement = m.Document.GetElement(appearanceAssetId) as AppearanceAssetElement; + if (appearanceAssetElement != null) + { + Asset renderingAsset = appearanceAssetElement.GetRenderingAsset(); + if (renderingAsset.Size == 0) + { + using (var enumerator = m.Document.Application.get_Assets((AssetType)4).ForwardIterator()) + { + while (enumerator.MoveNext()) + { + object obj = enumerator.Current; + Asset asset = (Asset)obj; + if (asset.Name == renderingAsset.Name && asset.LibraryName == renderingAsset.LibraryName) + { + return this.ParseAssetProperty(asset); + } + } + goto IL_00C3; + } + } + return this.ParseAssetProperty(renderingAsset); + } + } + IL_00C3: + return null; + } + + // Token: 0x06000031 RID: 49 RVA: 0x00003F1C File Offset: 0x0000211C + public RenderNodeAction OnInstanceBegin(InstanceNode node) + { + this.m_TransformationStack.Push(this.m_TransformationStack.Peek().Multiply(node.GetTransform())); + return 0; + } + + // Token: 0x06000032 RID: 50 RVA: 0x00003F40 File Offset: 0x00002140 + public void OnMaterial(MaterialNode node) + { + if (this.currentMaterialId != node.MaterialId) + { + this.currentMaterialId = node.MaterialId; + if (this.materialIds.Contains(this.currentMaterialId)) + { + return; + } + this.materialIds.Add(this.currentMaterialId); + this.currentColor = node.Color; + this.currentTransparency = 1.0 - node.Transparency; + this.swMtl.Write("\nnewmtl {0}\nka {1} {2} {3}\nkd {1} {2} {3}\nd {4}\n", new object[] + { + this.currentMaterialId.IntegerValue.ToString(), + ((double)this.currentColor.Red / 256.0).ToString(), + ((double)this.currentColor.Green / 256.0).ToString(), + ((double)this.currentColor.Blue / 256.0).ToString(), + this.currentTransparency + }); + if (node.HasOverriddenAppearance) + { + this.currentAsset = node.GetAppearanceOverride(); + } + else + { + this.currentAsset = node.GetAppearance(); + } + try + { + string text = this.ParseAssetProperty(this.GetTrueAsset(this.currentAsset)); + if (text != null) + { + string text2 = Regex.Replace(Path.GetDirectoryName(text), "[^0-9]+", ""); + this.textureName = Path.GetFileName(text).Replace(" ", "").Replace("&", "-") + .ToLower(); + if (text2 != null && text2.Length > 0) + { + this.textureName = Path.GetFileNameWithoutExtension(this.textureName) + "_" + text2 + Path.GetExtension(this.textureName); + } + string text3 = Path.Combine(this.textureLibraryPath, text.Replace("/", "\\")); + if (File.Exists(text3)) + { + this.swMtl.Write("map_Kd ./textures/" + this.textureName + "\n"); + File.Copy(text3, Path.Combine(this.resultTexturePath, this.textureName), true); + } + } + } + catch (Exception) + { + } + } + } + + // Token: 0x06000033 RID: 51 RVA: 0x0000417C File Offset: 0x0000237C + private Asset GetTrueAsset(Asset currentAsset) + { + if (currentAsset.Size == 0) + { + foreach (object obj in this.m_doc.Application.get_Assets((AssetType)4)) + { + Asset asset = (Asset)obj; + if (asset.Name == currentAsset.Name && asset.LibraryName == currentAsset.LibraryName) + { + return asset; + } + } + return null; + } + return currentAsset; + } + + // Token: 0x06000034 RID: 52 RVA: 0x00004210 File Offset: 0x00002410 + public void OnLight(LightNode node) + { + } + + // Token: 0x06000035 RID: 53 RVA: 0x00004212 File Offset: 0x00002412 + public void OnRPC(RPCNode node) + { + } + + // Token: 0x06000036 RID: 54 RVA: 0x00004214 File Offset: 0x00002414 + public RenderNodeAction OnFaceBegin(FaceNode node) + { + return 0; + } + + // Token: 0x06000037 RID: 55 RVA: 0x00004218 File Offset: 0x00002418 + public void OnPolymesh(PolymeshTopology node) + { + TextWriter textWriter = this.swObj; + string[] array = new string[5]; + array[0] = "g "; + array[1] = this.currentId.IntegerValue.ToString(); + array[2] = "-"; + int num = 3; + int integerValue = this.elementPolyIndex; + this.elementPolyIndex = integerValue + 1; + array[num] = integerValue.ToString(); + array[4] = "\n"; + textWriter.Write(string.Concat(array)); + this.swObj.Write("usemtl " + this.currentMaterialId.IntegerValue.ToString() + "\n"); + Transform currentTransform = this.m_TransformationStack.Peek(); + IEnumerable enumerable = (from p in node.GetPoints() + select currentTransform.OfPoint(p)).ToList(); + Dictionary dictionary = this.productTris; + integerValue = this.currentId.IntegerValue; + dictionary[integerValue] += node.NumberOfPoints; + foreach (XYZ xyz in enumerable) + { + XYZ xyz2 = xyz * Rvt2Obj.feetToMM; + this.swObj.Write(string.Concat(new string[] + { + "v ", + xyz2.X.ToString(), + " ", + xyz2.Y.ToString(), + " ", + xyz2.Z.ToString(), + "\n" + })); + } + foreach (UV uv in node.GetUVs()) + { + this.swObj.Write(string.Concat(new string[] + { + "vt ", + (uv.U * 0.3048).ToString(), + " ", + (uv.V * 0.3048).ToString(), + " 0.0\n" + })); + } + foreach (PolymeshFacet polymeshFacet in node.GetFacets()) + { + this.swObj.Write(string.Concat(new string[] + { + "f ", + (polymeshFacet.V1 + 1 + this.vIndex).ToString(), + "/", + (polymeshFacet.V1 + 1 + this.vIndex).ToString(), + " ", + (polymeshFacet.V2 + 1 + this.vIndex).ToString(), + "/", + (polymeshFacet.V2 + 1 + this.vIndex).ToString(), + " ", + (polymeshFacet.V3 + 1 + this.vIndex).ToString(), + "/", + (polymeshFacet.V3 + 1 + this.vIndex).ToString(), + "\n" + })); + } + this.vIndex += node.NumberOfPoints; + } + + // Token: 0x06000038 RID: 56 RVA: 0x000045D0 File Offset: 0x000027D0 + public void OnFaceEnd(FaceNode node) + { + } + + // Token: 0x06000039 RID: 57 RVA: 0x000045D2 File Offset: 0x000027D2 + public void OnInstanceEnd(InstanceNode node) + { + this.m_TransformationStack.Pop(); + } + + // Token: 0x0600003A RID: 58 RVA: 0x000045E0 File Offset: 0x000027E0 + public void OnElementEnd(ElementId elementId) + { + } + + // Token: 0x0600003B RID: 59 RVA: 0x000045E2 File Offset: 0x000027E2 + public void OnLinkEnd(LinkNode node) + { + } + + // Token: 0x0600003C RID: 60 RVA: 0x000045E4 File Offset: 0x000027E4 + public void OnViewEnd(ElementId elementId) + { + Utils_SendMessage.UpdateProgressUI(95, 95, 1.0); + File.WriteAllLines("D:\\huarun_0105.txt", (from x in this.productTris + orderby x.Value + select string.Format("{0} {1}", x.Key, x.Value)).ToArray()); + } + + // Token: 0x0600003D RID: 61 RVA: 0x00004660 File Offset: 0x00002860 + public bool IsCanceled() + { + return false; + } + + // Token: 0x0600003E RID: 62 RVA: 0x00004663 File Offset: 0x00002863 + public void Finish() + { + this.swObj.Close(); + this.swMtl.Close(); + } + + // Token: 0x0600003F RID: 63 RVA: 0x0000467C File Offset: 0x0000287C + private bool IsTextureAsset(Asset asset) + { + AssetProperty assetProperty = this.GetAssetProperty(asset, "assettype"); + return (assetProperty != null && (assetProperty as AssetPropertyString).Value == "texture") || this.GetAssetProperty(asset, "unifiedbitmap_Bitmap") != null; + } + + // Token: 0x06000040 RID: 64 RVA: 0x000046C4 File Offset: 0x000028C4 + private AssetProperty GetAssetProperty(Asset asset, string propertyName) + { + for (int i = 0; i < asset.Size; i++) + { + if (asset[i].Name == propertyName) + { + return asset[i]; + } + } + return null; + } + + // Token: 0x06000041 RID: 65 RVA: 0x00004700 File Offset: 0x00002900 + private Asset FindTextureAsset(AssetProperty ap) + { + Asset asset = null; + if (ap.Type == (AssetPropertyType)15) + { + if (!this.IsTextureAsset(ap as Asset)) + { + for (int i = 0; i < (ap as Asset).Size; i++) + { + if (this.FindTextureAsset((ap as Asset)[i]) != null) + { + return this.FindTextureAsset((ap as Asset)[i]); + } + } + } + else + { + asset = ap as Asset; + } + return asset; + } + for (int j = 0; j < ap.NumberOfConnectedProperties; j++) + { + if (this.FindTextureAsset(ap.GetConnectedProperty(j)) != null) + { + return this.FindTextureAsset(ap.GetConnectedProperty(j)); + } + } + return asset; + } + + // Token: 0x06000042 RID: 66 RVA: 0x000047A4 File Offset: 0x000029A4 + private string ParseAssetProperty(AssetProperty prop) + { + if (prop == null) + { + return null; + } + if (prop.Name == "unifiedbitmap_Bitmap") + { + string value = (prop as AssetPropertyString).Value; + if (value.Length > 0) + { + return value.Split(new char[] { '|' })[0]; + } + } + foreach (AssetProperty assetProperty in prop.GetAllConnectedProperties()) + { + string text = this.ParseAssetProperty(assetProperty); + if (text != null) + { + return text; + } + } + AssetPropertyType type = prop.Type; + if (type !=(AssetPropertyType) 1) + { + if (type != (AssetPropertyType)15) + { + if (type == (AssetPropertyType)19) + { + foreach (AssetProperty assetProperty2 in (prop as AssetPropertyList).GetValue()) + { + string text2 = this.ParseAssetProperty(assetProperty2); + if (text2 != null) + { + return text2; + } + } + } + } + else + { + Asset asset = prop as Asset; + for (int i = 0; i < asset.Size; i++) + { + AssetProperty assetProperty3 = asset[i]; + string text3 = this.ParseAssetProperty(assetProperty3); + if (text3 != null) + { + return text3; + } + } + } + } + else + { + AssetProperties assetProperties = prop as AssetProperties; + for (int j = 0; j < assetProperties.Size; j++) + { + AssetProperty assetProperty4 = assetProperties[j]; + string text4 = this.ParseAssetProperty(assetProperty4); + if (text4 != null) + { + return text4; + } + } + } + return null; + } + + // Token: 0x04000020 RID: 32 + private StreamWriter swObj; + + // Token: 0x04000021 RID: 33 + private StreamWriter swMtl; + + // Token: 0x04000022 RID: 34 + private const string strNewmtl = "\nnewmtl {0}\nka {1} {2} {3}\nkd {1} {2} {3}\nd {4}\n"; + + // Token: 0x04000023 RID: 35 + private ElementId currentMaterialId; + + // Token: 0x04000024 RID: 36 + private Color currentColor; + + // Token: 0x04000025 RID: 37 + private bool useElementTypeTexture; + + // Token: 0x04000026 RID: 38 + private HashSet texturePathes = new HashSet(); + + // Token: 0x04000027 RID: 39 + private HashSet materialIds = new HashSet(); + + // Token: 0x04000028 RID: 40 + private double currentTransparency; + + // Token: 0x04000029 RID: 41 + private Asset currentAsset; + + // Token: 0x0400002A RID: 42 + private int _precision; + + // Token: 0x0400002B RID: 43 + private Document m_doc; + + // Token: 0x0400002C RID: 44 + private Stack m_TransformationStack = new Stack(); + + // Token: 0x0400002D RID: 45 + private ElementId currentId; + + // Token: 0x0400002E RID: 46 + private int vIndex; + + // Token: 0x0400002F RID: 47 + private string textureLibraryPath = ""; + + // Token: 0x04000030 RID: 48 + private string textureName = ""; + + // Token: 0x04000031 RID: 49 + private string resultPath; + + // Token: 0x04000032 RID: 50 + private string resultTexturePath; + + // Token: 0x04000033 RID: 51 + private static double feetToMM = 304.8; + + // Token: 0x04000034 RID: 52 + private int elementPolyIndex; + + // Token: 0x04000035 RID: 53 + public int totalElementCount; + + // Token: 0x04000036 RID: 54 + private int currentElementCount; + + // Token: 0x04000037 RID: 55 + private Log log; + + // Token: 0x04000038 RID: 56 + private Dictionary productTris = new Dictionary(); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Settings_IFC.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Settings_IFC.cs new file mode 100644 index 0000000..dcb2e54 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/Settings_IFC.cs @@ -0,0 +1,58 @@ +using System; +using System.IO; +using IFC_Revit_Interop.Utils; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200001D RID: 29 + public class Settings_IFC + { + // Token: 0x04000081 RID: 129 + public static string ADDIN_PATH = typeof(Settings_IFC).Assembly.Location; + + // Token: 0x04000082 RID: 130 + public static string DIRECTORY = Path.GetDirectoryName(Settings_IFC.ADDIN_PATH); + + // Token: 0x04000083 RID: 131 + public static string INI_PATH = Path.Combine(Settings_IFC.DIRECTORY, "cbims_ifc.ini"); + + // Token: 0x04000084 RID: 132 + public static string LOG_PATH = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "LOG", "LOG_PATH", "cbims_ifc.log")); + + // Token: 0x04000085 RID: 133 + public static string LOG_SERVER_ONTEST = Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "LOG", "LOG_SERVER_ONTEST", "false"); + + // Token: 0x04000086 RID: 134 + public static string LISTEN_TO_SERVER = Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "REMOTE", "LISTEN_TO_SERVER", "false"); + + // Token: 0x04000087 RID: 135 + public static string DO_STAT = Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "REMOTE", "DO_STAT", "true"); + + // Token: 0x04000088 RID: 136 + public static string DO_COMPRESS = Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "REMOTE", "DO_COMPRESS", "false"); + + // Token: 0x04000089 RID: 137 + public static string MVDXML_IFC2X3 = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "MVDXML_IFC2X3", "")); + + // Token: 0x0400008A RID: 138 + public static string MVDXML_IFC4 = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "MVDXML_IFC4", "")); + + // Token: 0x0400008B RID: 139 + public static string MVDLITE_IFC2X3 = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "MVDLITE_IFC2X3", "")); + + // Token: 0x0400008C RID: 140 + public static string MVDLITE_IFC4 = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "MVDLITE_IFC4", "")); + + // Token: 0x0400008D RID: 141 + public static string EXPORT_COUNTDOWN = Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "EXPORT_COUNTDOWN", "5"); + + // Token: 0x0400008E RID: 142 + public static string RUN_COMPRESS_PATH = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "RUN_COMPRESS_PATH", "RunCompress.exe")); + + // Token: 0x0400008F RID: 143 + public static string RUN_TEXTURE_PATH = Path.Combine(Settings_IFC.DIRECTORY, Utils_Ini.IniReadValue(Settings_IFC.INI_PATH, "EXPORT", "RUN_TEXTURE_PATH", "RunTexture.exe")); + + // Token: 0x04000090 RID: 144 + public static string RUN_ProgressBar_PATH = Path.Combine(Settings_IFC.DIRECTORY, "ProgressBar.exe"); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/ClassificationInfo.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/ClassificationInfo.cs new file mode 100644 index 0000000..ae9f7c1 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/ClassificationInfo.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace IFC_Revit_Interop.TestTools +{ + // Token: 0x0200001F RID: 31 + public class ClassificationInfo + { + // Token: 0x04000091 RID: 145 + public HashSet FamilyNames = new HashSet(); + + // Token: 0x04000092 RID: 146 + public HashSet CategoryNames = new HashSet(); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/Command_ClassificationExportMulti.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/Command_ClassificationExportMulti.cs new file mode 100644 index 0000000..0381cc4 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/Command_ClassificationExportMulti.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; + +namespace IFC_Revit_Interop.TestTools +{ + // Token: 0x02000021 RID: 33 + [Transaction( TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_ClassificationExportMulti : IExternalCommand + { + // Token: 0x06000090 RID: 144 RVA: 0x00007B38 File Offset: 0x00005D38 + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + string text = "E:/_BIM/宜宾WDGC"; + List list = new List(); + Command_ClassificationExportMulti.FindFile(new DirectoryInfo(text), list); + Document document = null; + foreach (string text2 in list) + { + if (File.Exists(text2)) + { + UIDocument uidocument = commandData.Application.OpenAndActivateDocument(text2); + if (document != null) + { + document.Close(false); + } + new Command_Test_ClassificationExport().Execute(commandData, ref message, elements); + document = uidocument.Document; + } + } + return 0; + } + + // Token: 0x06000091 RID: 145 RVA: 0x00007BCC File Offset: 0x00005DCC + private static void FindFile(DirectoryInfo di, List record) + { + FileInfo[] files = di.GetFiles(); + for (int i = 0; i < files.Length; i++) + { + if (Path.GetExtension(files[i].FullName) == ".rvt") + { + record.Add(files[i].FullName); + } + } + DirectoryInfo[] directories = di.GetDirectories(); + for (int j = 0; j < directories.Length; j++) + { + Command_ClassificationExportMulti.FindFile(directories[j], record); + } + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/Command_Test_ClassificationExport.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/Command_Test_ClassificationExport.cs new file mode 100644 index 0000000..b556c74 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/TestTools/Command_Test_ClassificationExport.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using Newtonsoft.Json; + +namespace IFC_Revit_Interop.TestTools +{ + // Token: 0x02000020 RID: 32 + [Transaction(TransactionMode.Manual)] + [Regeneration(0)] + internal class Command_Test_ClassificationExport : IExternalCommand + { + // Token: 0x0600008E RID: 142 RVA: 0x000078DC File Offset: 0x00005ADC + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) + { + string text = "d:/record.json"; + Dictionary dictionary = new Dictionary(); + if (File.Exists(text)) + { + StreamReader streamReader = new StreamReader(text); + string text2 = streamReader.ReadToEnd(); + streamReader.Close(); + dictionary = JsonConvert.DeserializeObject>(text2); + } + Document document = commandData.Application.ActiveUIDocument.Document; + foreach (Element element in new FilteredElementCollector(document).WhereElementIsNotElementType().WhereElementIsViewIndependent()) + { + string text3 = null; + string text4 = null; + Element element2 = null; + if (element.Category != null) + { + text3 = element.Category.Name; + } + FamilyInstance familyInstance = element as FamilyInstance; + if (familyInstance != null) + { + element2 = familyInstance.Symbol; + text4 = familyInstance.Symbol.FamilyName; + } + else if (element.GetTypeId() != ElementId.InvalidElementId) + { + ElementType elementType = document.GetElement(element.GetTypeId()) as ElementType; + if (elementType != null) + { + element2 = elementType; + text4 = "系统族:" + elementType.FamilyName; + } + } + HashSet hashSet = new HashSet(); + Parameter parameter = element.LookupParameter("构件分类编码"); + if (parameter != null && parameter.HasValue) + { + string text5 = parameter.AsString(); + if (!string.IsNullOrEmpty(text5)) + { + hashSet.Add(text5); + } + } + if (element2 != null) + { + parameter = element2.LookupParameter("构件分类编码"); + if (parameter != null && parameter.HasValue) + { + string text6 = parameter.AsString(); + if (!string.IsNullOrEmpty(text6)) + { + hashSet.Add(text6); + } + } + } + foreach (string text7 in hashSet) + { + if (!dictionary.ContainsKey(text7)) + { + dictionary.Add(text7, new ClassificationInfo()); + } + if (text3 != null) + { + dictionary[text7].CategoryNames.Add(text3); + } + if (text4 != null) + { + dictionary[text7].FamilyNames.Add(text4); + } + } + } + string text8 = JsonConvert.SerializeObject(dictionary); + StreamWriter streamWriter = new StreamWriter(text); + streamWriter.Write(text8); + streamWriter.Close(); + return 0; + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ViewData.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ViewData.cs new file mode 100644 index 0000000..13b1adc --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ViewData.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Autodesk.Revit.DB; + +namespace IFC_Revit_Interop +{ + // Token: 0x0200000C RID: 12 + public class ViewData + { + // Token: 0x0600004B RID: 75 RVA: 0x00004F14 File Offset: 0x00003114 + public ViewData() + { + } + + // Token: 0x0600004C RID: 76 RVA: 0x00004F80 File Offset: 0x00003180 + public ViewData(View v) + { + this.ViewId = v.Id.IntegerValue; + this.ViewName = v.Name; + this.ViewOrigin.Add(v.Origin.X); + this.ViewOrigin.Add(v.Origin.Y); + this.ViewOrigin.Add(v.Origin.Z); + this.Scale = v.Scale; + this.ViewDirectionXYZ.Add(v.ViewDirection.X); + this.ViewDirectionXYZ.Add(v.ViewDirection.Y); + this.ViewDirectionXYZ.Add(v.ViewDirection.Z); + this.UpDirectionXYZ.Add(v.UpDirection.X); + this.UpDirectionXYZ.Add(v.UpDirection.Y); + this.UpDirectionXYZ.Add(v.UpDirection.Z); + this.RightDirectionXYZ.Add(v.RightDirection.X); + this.RightDirectionXYZ.Add(v.RightDirection.Y); + this.RightDirectionXYZ.Add(v.RightDirection.Z); + this.CropBoxActive = v.CropBoxActive; + if (v.CropBox.Enabled) + { + this.CropBox["Min"] = new List(); + this.CropBox["Min"].Add(v.CropBox.Min.X); + this.CropBox["Min"].Add(v.CropBox.Min.Y); + this.CropBox["Min"].Add(v.CropBox.Min.Z); + this.CropBox["Max"] = new List(); + this.CropBox["Max"].Add(v.CropBox.Max.X); + this.CropBox["Max"].Add(v.CropBox.Max.Y); + this.CropBox["Max"].Add(v.CropBox.Max.Z); + } + foreach (Element element in Command_ViewExport.GetAllInViewCollector(v).ToElements()) + { + if (!ViewData.IsElementOutsideCropBox(element, v)) + { + this.Elements.Add(new ElementData(element, this)); + } + } + this.GetFilterColorsAndElements(v); + } + + // Token: 0x0600004D RID: 77 RVA: 0x000052A0 File Offset: 0x000034A0 + private static bool IsElementOutsideCropBox(Element e, View v) + { + bool flag = v.CropBoxActive; + if (flag && v.CropBox.Enabled) + { + BoundingBoxXYZ cropBox = v.CropBox; + BoundingBoxXYZ boundingBoxXYZ = e.get_BoundingBox(v); + if (boundingBoxXYZ == null) + { + return true; + } + Transform inverse = v.CropBox.Transform.Inverse; + boundingBoxXYZ.Max = inverse.OfPoint(boundingBoxXYZ.Max); + boundingBoxXYZ.Min = inverse.OfPoint(boundingBoxXYZ.Min); + flag = boundingBoxXYZ.Min.X > cropBox.Max.X || boundingBoxXYZ.Max.X < cropBox.Min.X || boundingBoxXYZ.Min.Y > cropBox.Max.Y || boundingBoxXYZ.Max.Y < cropBox.Min.Y || boundingBoxXYZ.Min.Z > cropBox.Max.Z || boundingBoxXYZ.Max.Z < cropBox.Min.Z; + } + return flag; + } + + // Token: 0x0600004E RID: 78 RVA: 0x000053A8 File Offset: 0x000035A8 + public void GetFilterColorsAndElements(View view) + { + HashSet hashSet = new HashSet(); + foreach (ElementData elementData in this.Elements) + { + hashSet.Add(elementData.Id); + } + Document document = view.Document; + try + { + foreach (ElementId elementId in view.GetFilters()) + { + if (view.IsFilterApplied(elementId)) + { + FilterElement filterElement = document.GetElement(elementId) as FilterElement; + ICollection collection = null; + if (filterElement is ParameterFilterElement) + { + FilteredElementCollector filteredElementCollector = new FilteredElementCollector(document); + ParameterFilterElement parameterFilterElement = filterElement as ParameterFilterElement; + ICollection categories = parameterFilterElement.GetCategories(); + if (categories.Count > 0) + { + ElementMulticategoryFilter elementMulticategoryFilter = new ElementMulticategoryFilter(categories); + filteredElementCollector = filteredElementCollector.WherePasses(elementMulticategoryFilter); + } + ICollection rules = parameterFilterElement.GetRules(); + if (rules.Count > 0) + { + ElementParameterFilter elementParameterFilter = new ElementParameterFilter(rules.ToList()); + filteredElementCollector = filteredElementCollector.WherePasses(elementParameterFilter); + } + collection = filteredElementCollector.ToElementIds(); + } + else if (filterElement is SelectionFilterElement) + { + collection = (filterElement as SelectionFilterElement).GetElementIds(); + } + if (collection.Count != 0) + { + Color projectionFillColor = view.GetFilterOverrides(elementId).ProjectionFillColor; + if (projectionFillColor.IsValid) + { + string name = filterElement.Name; + this.FilterColors[name] = new List(); + this.FilterColors[name].Add((int)projectionFillColor.Red); + this.FilterColors[name].Add((int)projectionFillColor.Green); + this.FilterColors[name].Add((int)projectionFillColor.Blue); + this.FilterCoveredElements[name] = new List(); + foreach (ElementId elementId2 in collection) + { + if (hashSet.Contains(elementId2.IntegerValue)) + { + this.FilterCoveredElements[name].Add(elementId2.IntegerValue); + } + } + } + } + } + } + } + catch (Exception ex) + { + throw ex; + } + } + + // Token: 0x0400003A RID: 58 + public int ViewId; + + // Token: 0x0400003B RID: 59 + public string ViewName; + + // Token: 0x0400003C RID: 60 + public List ViewOrigin = new List(); + + // Token: 0x0400003D RID: 61 + public int Scale; + + // Token: 0x0400003E RID: 62 + public List ViewDirectionXYZ = new List(); + + // Token: 0x0400003F RID: 63 + public List UpDirectionXYZ = new List(); + + // Token: 0x04000040 RID: 64 + public List RightDirectionXYZ = new List(); + + // Token: 0x04000041 RID: 65 + public bool CropBoxActive; + + // Token: 0x04000042 RID: 66 + public Dictionary> CropBox = new Dictionary>(); + + // Token: 0x04000043 RID: 67 + public List Elements = new List(); + + // Token: 0x04000044 RID: 68 + public Dictionary> FilterColors = new Dictionary>(); + + // Token: 0x04000045 RID: 69 + public Dictionary> FilterCoveredElements = new Dictionary>(); + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ZeroDocAvailability.cs b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ZeroDocAvailability.cs new file mode 100644 index 0000000..aa578b0 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop/ZeroDocAvailability.cs @@ -0,0 +1,16 @@ +using System; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; + +namespace IFC_Revit_Interop +{ + // Token: 0x02000007 RID: 7 + public class ZeroDocAvailability : IExternalCommandAvailability + { + // Token: 0x0600001F RID: 31 RVA: 0x0000384F File Offset: 0x00001A4F + public bool IsCommandAvailable(UIApplication a, CategorySet b) + { + return true; + } + } +} diff --git a/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop_VERSION_2018.csproj b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop_VERSION_2018.csproj new file mode 100644 index 0000000..06c971d --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/IFC_Revit_Interop_VERSION_2018.csproj @@ -0,0 +1,155 @@ + + + + + Debug + AnyCPU + {3916BB83-6282-4A88-B5A3-0FD79B1DF2E0} + Library + IFC_Revit_Interop_VERSION_2018 + IFC_Revit_Interop_VERSION_2018 + v4.7.2 + 512 + {60DC8134-EBA5-43B8-BCC9-BB4BC16C2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.InterIFC.IFC.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.InterIFC.STEP.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.MVD.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.MVD.InterIfc.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.MVDLite.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.MVDLite.Checker.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.STEParser.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.STEParser.EB.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\CBIMS.STEParser.Translate.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\IFC_ExcelReport.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\Microsoft.WindowsAPICodePack.Shell.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\Newtonsoft.Json.dll + + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\Revit.IFC.CBMod.Common_VERSION_2018.dll + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\Revit.IFC.CBMod.Export_VERSION_2018.dll + + + C:\Program Files\Autodesk\Revit 2018\RevitAPI.dll + False + + + C:\Program Files\Autodesk\Revit 2018\RevitAPIIFC.dll + False + + + C:\Program Files\Autodesk\Revit 2018\RevitAPIUI.dll + False + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\RunCompress.exe + + + + + + + C:\ProgramData\Autodesk\Revit\Addins\CBIMS_IFC_Revit_Interop\Toolkit_Utils.dll + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + FormExportCountdown.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/IFC_Revit_Interop_VERSION_2018/Properties/AssemblyInfo.cs b/IFC_Revit_Interop_VERSION_2018/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8fe6007 --- /dev/null +++ b/IFC_Revit_Interop_VERSION_2018/Properties/AssemblyInfo.cs @@ -0,0 +1,14 @@ +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; + +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyCompany("THU")] +[assembly: AssemblyConfiguration("Release")] +[assembly: AssemblyFileVersion("1.3.0.0")] +[assembly: AssemblyInformationalVersion("1.3.0")] +[assembly: AssemblyProduct("IFC_Revit_Interop_VERSION_2018")] +[assembly: AssemblyTitle("IFC_Revit_Interop_VERSION_2018")] +[assembly: AssemblyMetadata("RepositoryUrl", "")]