-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathExportOptionsCache.cs
More file actions
1089 lines (959 loc) · 39.2 KB
/
Copy pathExportOptionsCache.cs
File metadata and controls
1089 lines (959 loc) · 39.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// BIM IFC library: this library works with Autodesk(R) Revit(R) to export IFC files containing model geometry.
// Copyright (C) 2012-2016 Autodesk, Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.IFC;
using Revit.IFC.Common.Enums;
using Revit.IFC.Common.Utility;
using Revit.IFC.Common.Extensions;
using System.Text.RegularExpressions;
// CQ_TODO: Better storage of pipe insulation options
namespace Revit.IFC.Export.Utility
{
/// <summary>
/// The cache which holds all export options.
/// </summary>
public class ExportOptionsCache
{
public SiteTransformBasis SiteTransformation { get; set; } = SiteTransformBasis.Shared;
public enum ExportTessellationLevel
{
ExtraLow = 1,
Low = 2,
Medium = 3,
High = 4
}
private GUIDOptions m_GUIDOptions;
private IFCVersion m_FileVersion;
public COBieCompanyInfo COBieCompanyInfo { get; set; }
public COBieProjectInfo COBieProjectInfo { get; set; }
public IFCFileHeaderItem FileHeaderItem { get; private set; }
private KnownERNames m_exchangeRequirement = KnownERNames.NotDefined;
public KnownERNames GetExchangeRequirement { get { return m_exchangeRequirement; } }
public string GeoRefCRSName { get; private set; }
public string GeoRefCRSDesc { get; private set; }
public string GeoRefEPSGCode { get; private set; }
public string GeoRefGeodeticDatum { get; private set; }
public string GeoRefMapUnit { get; private set; }
public bool IncludeSteelElements { get; set; }
/// Private default constructor.
/// </summary>
private ExportOptionsCache()
{
}
/// <summary>
/// de-serialize vector passed from UI trough options
/// </summary>
private static XYZ ParseXYZ(string value)
{
XYZ retVal = null;
//split string to components by removing seprator characters
string[] separator = new string[] { ",", "(", ")", " " };
string[] sList = new string[3] { "", "", "" };
sList = value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
//should remain only 3 values if everything is OK
try
{
// XYZ values are serialized in Revit using C++ format, which seems to use invariant culture.
// Better yet would be not to pass doubles as strings, but this is a fairly limited use and
// easily worked around here.
double valX = double.Parse(sList[0], CultureInfo.InvariantCulture); //parsing values
double valY = double.Parse(sList[1], CultureInfo.InvariantCulture);
double valZ = double.Parse(sList[2], CultureInfo.InvariantCulture);
//if no exception then put it in return value
retVal = new XYZ(valX, valY, valZ);
}
catch (FormatException)
{
}
//return null if there is a problem or a value
return retVal;
}
/// <summary>
/// de-serialize transform passed from UI trough options
/// </summary>
private static Transform ParseTransform(string value)
{
Transform retVal = null;
try
{
//spit string by separator; it should remain 4 items
string[] separator = new string[] { ";" };
string[] sList = new string[4] { "", "", "", "" };
sList = value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
Transform tr = new Transform(Transform.Identity);
// parse each item in part
tr.Origin = ParseXYZ(sList[0]);
tr.BasisX = ParseXYZ(sList[1]);
tr.BasisY = ParseXYZ(sList[2]);
tr.BasisZ = ParseXYZ(sList[3]);
// verify if value was correctly parsed
if (tr.Origin != null && tr.BasisX != null &&
tr.BasisY != null && tr.BasisZ != null)
retVal = tr;
}
catch
{
retVal = null;
}
//return value
return retVal;
}
private static ElementId ParseElementId(String singleElementValue)
{
int elementIdAsInt;
if (Int32.TryParse(singleElementValue, out elementIdAsInt))
{
return new ElementId(elementIdAsInt);
}
else
{
// Error - the option supplied could not be mapped to int.
// TODO: consider logging this error later and handling results better.
throw new Exception("String did not map to a usable element id");
}
}
private static IList<ElementId> ParseElementIds(String elementsToExportValue)
{
String[] elements = elementsToExportValue.Split(';');
List<ElementId> ids = new List<ElementId>();
foreach (String element in elements)
{
int elementIdAsInt;
if (Int32.TryParse(element, out elementIdAsInt))
{
ids.Add(new ElementId(elementIdAsInt));
}
else
{
// Error - the option supplied could not be mapped to int.
// TODO: consider logging this error later and handling results better.
throw new Exception("Substring " + element + " did not map to a usable element id");
}
}
return ids;
}
/// <summary>
/// Creates a new export options cache from the data in the ExporterIFC passed from Revit.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC handle passed during export.</param>
/// <returns>The new cache.</returns>
public static ExportOptionsCache Create(ExporterIFC exporterIFC, Document document, Autodesk.Revit.DB.View filterView)
{
IDictionary<String, String> options = exporterIFC.GetOptions();
ExportOptionsCache cache = new ExportOptionsCache();
cache.FileVersion = exporterIFC.FileVersion;
cache.FileName = exporterIFC.FileName;
cache.ExportBaseQuantities = exporterIFC.ExportBaseQuantities;
cache.WallAndColumnSplitting = exporterIFC.WallAndColumnSplitting;
cache.SpaceBoundaryLevel = exporterIFC.SpaceBoundaryLevel;
// Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected. Or if it is exported as IFC4RV
cache.ExportParts = (filterView != null && filterView.PartsVisibility == PartsVisibility.ShowPartsOnly);
cache.ExportPartsAsBuildingElementsOverride = null;
cache.ExportAnnotationsOverride = null;
// We are going to default to "true" for IncludeSteelElements to allow the default API
// export to match the default UI.
bool? includeSteelElements = OptionsUtil.GetNamedBooleanOption(options, "IncludeSteelElements");
cache.IncludeSteelElements = includeSteelElements.HasValue && includeSteelElements.Value;
// There is a bug in the native code that doesn't allow us to cast the filterView to any sub-type of View. Work around this by re-getting the element pointer.
if (filterView != null)
cache.FilterViewForExport = filterView.Document.GetElement(filterView.Id) as View;
else
cache.FilterViewForExport = null;
cache.ExportBoundingBoxOverride = null;
cache.IncludeSiteElevation = false;
cache.PropertySetOptions = PropertySetOptions.Create(exporterIFC, cache);
String use2DRoomBoundary = Environment.GetEnvironmentVariable("Use2DRoomBoundaryForRoomVolumeCalculationOnIFCExport");
bool? use2DRoomBoundaryOption = OptionsUtil.GetNamedBooleanOption(options, "Use2DRoomBoundaryForVolume");
cache.Use2DRoomBoundaryForRoomVolumeCreation =
((use2DRoomBoundary != null && use2DRoomBoundary == "1") ||
cache.ExportAs2x2 ||
(use2DRoomBoundaryOption != null && use2DRoomBoundaryOption.GetValueOrDefault()));
bool? exportAdvancedSweptSolids = OptionsUtil.GetNamedBooleanOption(options, "ExportAdvancedSweptSolids");
cache.ExportAdvancedSweptSolids = (exportAdvancedSweptSolids.HasValue) ? exportAdvancedSweptSolids.Value : false;
// Set GUIDOptions here.
{
// This option should be rarely used, and is only for consistency with old files. As such, it is set by environment variable only.
String use2009GUID = Environment.GetEnvironmentVariable("Assign2009GUIDToBuildingStoriesOnIFCExport");
cache.GUIDOptions.Use2009BuildingStoreyGUIDs = (use2009GUID != null && use2009GUID == "1");
bool? allowGUIDParameterOverride = OptionsUtil.GetNamedBooleanOption(options, "AllowGUIDParameterOverride");
if (allowGUIDParameterOverride != null)
cache.GUIDOptions.AllowGUIDParameterOverride = allowGUIDParameterOverride.Value;
bool? storeIFCGUID = OptionsUtil.GetNamedBooleanOption(options, "StoreIFCGUID");
if (storeIFCGUID != null)
cache.GUIDOptions.StoreIFCGUID = storeIFCGUID.Value;
}
// Set NamingOptions here.
cache.NamingOptions = new NamingOptions();
{
bool? useFamilyAndTypeNameForReference = OptionsUtil.GetNamedBooleanOption(options, "UseFamilyAndTypeNameForReference");
cache.NamingOptions.UseFamilyAndTypeNameForReference =
(useFamilyAndTypeNameForReference != null) && useFamilyAndTypeNameForReference.GetValueOrDefault();
bool? useVisibleRevitNameAsEntityName = OptionsUtil.GetNamedBooleanOption(options, "UseVisibleRevitNameAsEntityName");
cache.NamingOptions.UseVisibleRevitNameAsEntityName =
(useVisibleRevitNameAsEntityName != null) && useVisibleRevitNameAsEntityName.GetValueOrDefault();
bool? useOnlyTypeNameForIfcType = OptionsUtil.GetNamedBooleanOption(options, "UseTypeNameOnlyForIfcType");
cache.NamingOptions.UseTypeNameOnlyForIfcType =
(useOnlyTypeNameForIfcType != null) && useOnlyTypeNameForIfcType.GetValueOrDefault();
}
// "SingleElement" export option - useful for debugging - only one input element will be processed for export
String singleElementValue;
String elementsToExportValue;
if (options.TryGetValue("SingleElement", out singleElementValue))
{
ElementId elementId = ParseElementId(singleElementValue);
List<ElementId> ids = new List<ElementId>();
ids.Add(elementId);
cache.ElementsForExport = ids;
}
else if (options.TryGetValue("ElementsForExport", out elementsToExportValue))
{
IList<ElementId> ids = ParseElementIds(elementsToExportValue);
cache.ElementsForExport = ids;
}
else
{
cache.ElementsForExport = new List<ElementId>();
}
// "ExportAnnotations" override
cache.ExportAnnotationsOverride = OptionsUtil.GetNamedBooleanOption(options, "Export2DElements");
// "ExportSeparateParts" override
cache.ExportPartsAsBuildingElementsOverride = OptionsUtil.GetNamedBooleanOption(options, "ExportPartsAsBuildingElements");
// "ExportBoundingBox" override
cache.ExportBoundingBoxOverride = OptionsUtil.GetNamedBooleanOption(options, "ExportBoundingBox");
bool? exportRoomsInView = OptionsUtil.GetNamedBooleanOption(options, "ExportRoomsInView");
cache.ExportRoomsInView = exportRoomsInView != null ? exportRoomsInView.Value : false;
// Using the alternate UI or not.
cache.AlternateUIVersionOverride = OptionsUtil.GetNamedStringOption(options, "AlternateUIVersion");
// Include IFCSITE elevation in the site local placement origin
bool? includeIfcSiteElevation = OptionsUtil.GetNamedBooleanOption(options, "IncludeSiteElevation");
cache.IncludeSiteElevation = includeIfcSiteElevation != null ? includeIfcSiteElevation.Value : false;
string siteTransformation = OptionsUtil.GetNamedStringOption(options, "SitePlacement");
if (!string.IsNullOrEmpty(siteTransformation))
{
SiteTransformBasis trfBasis = SiteTransformBasis.Shared;
if (Enum.TryParse(siteTransformation, out trfBasis))
cache.SiteTransformation = trfBasis;
}
// We have two ways to get information about level of detail:
// 1. The old Boolean "UseCoarseTessellation".
// 2. The new double "TessellationLevelOfDetail".
// We will combine these both into a LevelOfDetail integer that can be used by different elements differently.
// The scale is from 1 (Extra Low) to 4 (High), where :
// UseCoarseTessellation = true -> 1, UseCoarseTessellation = false -> 4
// TessellationLevelOfDetail * 4 = LevelOfDetail
// TessellationLevelOfDetail takes precedence over UseCoarseTessellation.
cache.LevelOfDetail = ExportTessellationLevel.Low;
bool? useCoarseTessellation = OptionsUtil.GetNamedBooleanOption(options, "UseCoarseTessellation");
if (useCoarseTessellation.HasValue)
cache.LevelOfDetail = useCoarseTessellation.Value ? ExportTessellationLevel.ExtraLow : ExportTessellationLevel.High;
double? tessellationLOD = OptionsUtil.GetNamedDoubleOption(options, "TessellationLevelOfDetail");
if (tessellationLOD.HasValue)
{
int levelOfDetail = (int)(tessellationLOD.Value * 4.0 + 0.5);
// Ensure LOD is between 1 to 4, inclusive.
levelOfDetail = Math.Min(Math.Max(levelOfDetail, 1), 4);
cache.LevelOfDetail = (ExportTessellationLevel)levelOfDetail;
}
bool? useOnlyTriangulation = OptionsUtil.GetNamedBooleanOption(options, "UseOnlyTriangulation");
cache.UseOnlyTriangulation = useOnlyTriangulation.HasValue ? useOnlyTriangulation.Value : false;
/// Allow exporting a mix of extrusions and BReps as a solid model, if possible.
bool? canExportSolidModelRep = OptionsUtil.GetNamedBooleanOption(options, "ExportSolidModelRep");
cache.CanExportSolidModelRep = canExportSolidModelRep != null ? canExportSolidModelRep.Value : false;
// Set the phase we are exporting
cache.ActivePhaseId = ElementId.InvalidElementId;
String activePhaseElementValue;
if (options.TryGetValue("ActivePhaseId", out activePhaseElementValue))
cache.ActivePhaseId = ParseElementId(activePhaseElementValue);
if ((cache.ActivePhaseId == ElementId.InvalidElementId) && (cache.FilterViewForExport != null))
{
Parameter currPhase = cache.FilterViewForExport.get_Parameter(BuiltInParameter.VIEW_PHASE);
if (currPhase != null)
cache.ActivePhaseId = currPhase.AsElementId();
}
if (cache.ActivePhaseId == ElementId.InvalidElementId)
{
PhaseArray phaseArray = document.Phases;
Phase lastPhase = phaseArray.get_Item(phaseArray.Size - 1);
cache.ActivePhaseId = lastPhase.Id;
cache.ActivePhaseElement = lastPhase;
}
else
{
cache.ActivePhaseElement = document.GetElement(cache.ActivePhaseId) as Phase;
}
bool? useActiveViewGeometry = OptionsUtil.GetNamedBooleanOption(options, "UseActiveViewGeometry");
cache.UseActiveViewGeometry = useActiveViewGeometry.HasValue ? useActiveViewGeometry.Value : false;
if (cache.UseActiveViewGeometry)
{
int? viewId = OptionsUtil.GetNamedIntOption(options, "ActiveViewId");
int activeViewId = viewId.HasValue ? viewId.Value : -1;
View activeView = null;
try
{
activeView = document.GetElement(new ElementId(activeViewId)) as View;
}
catch
{
}
cache.ActiveView = activeView;
}
bool? exportAllPhases = OptionsUtil.GetNamedBooleanOption(options, "ExportAllPhases");
cache.ExportAllPhases = exportAllPhases.HasValue ? exportAllPhases.Value : false;
// "FileType" - note - setting is not respected yet
ParseFileType(options, cache);
string erName = OptionsUtil.GetNamedStringOption(options, "ExchangeRequirement");
Enum.TryParse(erName, out cache.m_exchangeRequirement);
// Get stored File Header information from the UI and use it for export
IFCFileHeaderItem fileHeaderItem = new IFCFileHeaderItem();
new IFCFileHeader().GetSavedFileHeader(document, out fileHeaderItem);
if (cache.m_exchangeRequirement != KnownERNames.NotDefined)
{
// It override existing value (if present) in the saved FileHeader, to use the selected ER from the UI
fileHeaderItem.FileDescription = "ExchangeRequirement [" + erName + "]";
}
cache.FileHeaderItem = fileHeaderItem;
cache.SelectedConfigName = OptionsUtil.GetNamedStringOption(options, "ConfigName");
cache.SelectedParametermappingTableName = OptionsUtil.GetNamedStringOption(options, "ExportUserDefinedParameterMappingFileName");
bool? bExportLinks = OptionsUtil.GetNamedBooleanOption(options, "ExportingLinks");
cache.ExportingLink = (bExportLinks.HasValue && bExportLinks.Value == true);
if (cache.ExportingLink)
{
int? numInstances = OptionsUtil.GetNamedIntOption(options, "NumberOfExportedLinkInstances");
for (int ii = 0; ii < numInstances; ii++)
{
string optionName = (ii == 0) ? "ExportLinkInstanceTransform" : "ExportLinkInstanceTransform" + (ii + 1).ToString();
String aLinkInstanceTransform = OptionsUtil.GetNamedStringOption(options, optionName);
Transform currTransform = null;
if (!String.IsNullOrEmpty(aLinkInstanceTransform))
{
//reconstruct transform
Transform tr = ParseTransform(aLinkInstanceTransform);
//set to cache
if (tr != null)
currTransform = tr;
}
string fileName = null;
if (ii > 0)
{
optionName = "ExportLinkInstanceFileName" + (ii + 1).ToString();
fileName = OptionsUtil.GetNamedStringOption(options, optionName);
}
if (currTransform == null)
cache.m_LinkInstanceInfos.Add(new Tuple<string, Transform>(fileName, Transform.Identity));
else
cache.m_LinkInstanceInfos.Add(new Tuple<string, Transform>(fileName, currTransform));
}
}
cache.ExcludeFilter = OptionsUtil.GetNamedStringOption(options, "ExcludeFilter");
// Geo Reference info
cache.GeoRefCRSName = OptionsUtil.GetNamedStringOption(options, "GeoRefCRSName");
cache.GeoRefCRSDesc = OptionsUtil.GetNamedStringOption(options, "GeoRefCRSDesc");
cache.GeoRefEPSGCode = OptionsUtil.GetNamedStringOption(options, "GeoRefEPSGCode");
cache.GeoRefGeodeticDatum = OptionsUtil.GetNamedStringOption(options, "GeoRefGeodeticDatum");
cache.GeoRefMapUnit = OptionsUtil.GetNamedStringOption(options, "GeoRefMapUnit");
return cache;
}
/// <summary>
/// Utility for parsing IFC file type.
/// </summary>
/// <remarks>
/// If the file type can't be retrieved from the options collection, it will parse the file name extension.
/// </remarks>
/// <param name="options">The collection of named options for IFC export.</param>
/// <param name="cache">The export options cache.</param>
private static void ParseFileType(IDictionary<String, String> options, ExportOptionsCache cache)
{
String fileTypeString;
if (options.TryGetValue("IFCFileType", out fileTypeString))
{
IFCFileFormat fileType;
if (Enum.TryParse<IFCFileFormat>(fileTypeString, true, out fileType))
{
cache.IFCFileFormat = fileType;
}
else
{
// Error - the option supplied could not be mapped to ExportFileType.
// TODO: consider logging this error later and handling results better.
throw new Exception("Option 'FileType' did not match an existing IFCFileFormat value");
}
}
else if (!string.IsNullOrEmpty(cache.FileName))
{
if (cache.FileName.EndsWith(".ifcXML")) //localization?
{
cache.IFCFileFormat = IFCFileFormat.IfcXML;
}
else if (cache.FileName.EndsWith(".ifcZIP"))
{
cache.IFCFileFormat = IFCFileFormat.IfcZIP;
}
else
{
cache.IFCFileFormat = IFCFileFormat.Ifc;
}
}
}
/// <summary>
/// The property set options.
/// </summary>
public PropertySetOptions PropertySetOptions
{
get;
set;
}
/// <summary>
/// The file version.
/// Used in ExportIntializer to define the Property Sets.
/// Try not to use it outside of ExportOptionsCache except to initialize the Property Sets.
/// </summary>
public IFCVersion FileVersion
{
get
{
return m_FileVersion;
}
set
{
m_FileVersion = value;
}
}
/// <summary>
/// The file name.
/// </summary>
public string FileName
{
get;
set;
}
/// <summary>
/// Identifies if the schema version being exported is IFC 2x2.
/// </summary>
public bool ExportAs2x2
{
get
{
return OptionsUtil.ExportAs2x2(FileVersion);
}
}
/// <summary>
/// Identifies if the schema version being exported is IFC 2x3 Coordination View 1.0.
/// </summary>
public bool ExportAs2x3CoordinationView1
{
get
{
return OptionsUtil.ExportAs2x3CoordinationView1(FileVersion);
}
}
/// <summary>
/// Identifies if the schema version being exported is IFC 2x3 Coordination View 2.0.
/// </summary>
public bool ExportAs2x3CoordinationView2
{
get
{
return OptionsUtil.ExportAs2x3CoordinationView2(FileVersion);
}
}
/// <summary>
/// Identifies if the schema version being exported is IFC 2x3 Extended FM Handover View (e.g., UK COBie).
/// </summary>
public bool ExportAs2x3ExtendedFMHandoverView
{
get
{
return OptionsUtil.ExportAs2x3ExtendedFMHandoverView(FileVersion);
}
}
/// <summary>
/// Identifies if the schema version and MVD being exported is IFC 2x3 Coordination View 2.0 or any IFC 4 MVD.
/// </summary>
/// <remarks>IFC 4 Coordination View 2.0 is not a real MVD; this was a placeholder and is obsolete.</remarks>
public bool ExportAsCoordinationView2
{
get
{
return OptionsUtil.ExportAsCoordinationView2(FileVersion);
}
}
/// <summary>
/// Identifies if the IFC schema version is older than IFC 4.
/// </summary>
public bool ExportAsOlderThanIFC4
{
get
{
return OptionsUtil.ExportAsOlderThanIFC4(FileVersion);
}
}
/// <summary>
/// Identifies if the IFC schema version being exported is IFC 4.
/// </summary>
public bool ExportAs4
{
get
{
return OptionsUtil.ExportAs4(FileVersion);
}
}
/// <summary>
/// Identifies if the schema used is IFC 2x3.
/// </summary>
public bool ExportAs2x3
{
get
{
return OptionsUtil.ExportAs2x3(FileVersion);
}
}
/// <summary>
/// Identifies if the schema and MVD used is the IFC 2x3 GSA 2010 COBie specification.
/// </summary>
public bool ExportAsCOBIE
{
get
{
return OptionsUtil.ExportAsCOBIE(FileVersion);
}
}
/// <summary>
/// Identifies if the schema and MVD used is the IFC 4 Reference View.
/// </summary>
public bool ExportAs4ReferenceView
{
get
{
return OptionsUtil.ExportAs4ReferenceView(FileVersion);
}
}
/// <summary>
/// Identifies if the schema and MVD used is the IFC 4 Design Transfer View.
/// </summary>
public bool ExportAs4DesignTransferView
{
get
{
return OptionsUtil.ExportAs4DesignTransferView(FileVersion);
}
}
/// <summary>
/// Option to be used for general IFC4 export (not specific to RV or DTV MVDs). Useful when there is a need to export entities that are not strictly valid within RV or DTV
/// It should work like IFC2x3, except that it will use IFC4 tessellated geometry instead of IFC2x3 BREP
/// </summary>
public bool ExportAs4General
{
get
{
return OptionsUtil.ExportAs4General(FileVersion);
}
}
/// <summary>
/// Identifies if the schema and MVD used is the IFC 2x3 COBie 2.4 Design Deliverable.
/// </summary>
public bool ExportAs2x3COBIE24DesignDeliverable
{
get
{
return OptionsUtil.ExportAs2x3COBIE24DesignDeliverable(FileVersion);
}
}
/// <summary>
/// Cache variable for the export annotations override (if set independently via the UI or API inputs)
/// </summary>
private bool? ExportAnnotationsOverride
{
get;
set;
}
/// <summary>
/// Identifies if the file version being exported supports annotations.
/// </summary>
public bool ExportAnnotations
{
get
{
if (ExportAnnotationsOverride != null)
return (bool)ExportAnnotationsOverride;
return (!ExportAs2x2 && !ExportAsCoordinationView2);
}
}
/// <summary>
/// Identifies if we allow exporting advanced swept solids (vs. BReps if false).
/// </summary>
public bool ExportAdvancedSweptSolids
{
get;
set;
}
/// <summary>
/// Whether or not split walls and columns.
/// </summary>
public bool WallAndColumnSplitting
{
get;
set;
}
/// <summary>
/// Whether or not export base quantities.
/// </summary>
public bool ExportBaseQuantities
{
get;
set;
}
/// <summary>
/// The space boundary level.
/// </summary>
public int SpaceBoundaryLevel
{
get;
set;
}
/// <summary>
/// True to use the active view when generating geometry.
/// False to use default export options.
/// </summary>
public bool UseActiveViewGeometry
{
get;
set;
}
/// <summary>
/// True to export all elements regardless of phase
/// False to use default export options.
/// </summary>
public bool ExportAllPhases
{
get;
set;
}
/// <summary>
/// Whether or not export the Part element from host.
/// Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected.
/// </summary>
public bool ExportParts
{
get;
set;
}
/// <summary>
/// Cache variable for the ExportPartsAsBuildingElements override (if set independently via the UI)
/// </summary>
public bool? ExportPartsAsBuildingElementsOverride
{
get;
set;
}
/// <summary>
/// Whether or not export the Parts as independent building elements.
/// Only if allows export parts and 'Export parts as building elements' is selected.
/// </summary>
public bool ExportPartsAsBuildingElements
{
get
{
if (ExportPartsAsBuildingElementsOverride != null)
return (bool)ExportPartsAsBuildingElementsOverride;
return false;
}
}
/// <summary>
/// Cache variable for the ExportBoundingBox override (if set independently via the UI)
/// </summary>
public bool? ExportBoundingBoxOverride
{
get;
set;
}
/// <summary>
/// Whether or not export the bounding box.
/// </summary>
public bool ExportBoundingBox
{
get
{
// if the option is set by alternate UI, return the setting in UI.
if (ExportBoundingBoxOverride != null)
return (bool)ExportBoundingBoxOverride;
// otherwise export the bounding box only if it is GSA export.
else if (FileVersion == IFCVersion.IFCCOBIE)
return true;
return false;
}
}
/// <summary>
/// Whether or not include IFCSITE elevation in the site local placement origin.
/// </summary>
public bool IncludeSiteElevation
{
get;
set;
}
/// <summary>
/// The level of detail to use when exporting geometry. Different elements will use this differently.
/// </summary>
public ExportTessellationLevel LevelOfDetail
{
get;
set;
}
/// <summary>
/// The option to leave tessellation results as triangulation and not optimized into polygonal faceset (supported from IFC4_ADD2)
/// </summary>
public bool UseOnlyTriangulation
{
get;
set;
}
/// <summary>
/// Cache variable for the Alternate UI version override (if export from Alternate UI)
/// </summary>
public string AlternateUIVersionOverride
{
get;
set;
}
/// <summary>
/// The UI Version of the exporter.
/// </summary>
public string ExporterUIVersion
{
get
{
if (AlternateUIVersionOverride != null)
return AlternateUIVersionOverride;
else
return "Default UI";
}
}
/// <summary>
/// The version of the exporter.
/// </summary>
public string ExporterVersion
{
get
{
string assemblyFile = typeof(Revit.IFC.Export.Exporter.Exporter).Assembly.Location;
string exporterVersion = "Unknown Exporter version";
if (File.Exists(assemblyFile))
{
exporterVersion = "Exporter " + FileVersionInfo.GetVersionInfo(assemblyFile).FileVersion;
}
return exporterVersion;
}
}
/// <summary>
/// A collection of elements from which to export (before filtering is applied). If empty, all elements in the document
/// are used as the initial set of elements before filtering is applied.
/// </summary>
public IList<ElementId> ElementsForExport
{
get;
set;
}
/// <summary>
/// The filter view for export.
/// </summary>
/// <remarks>This is the optional view that determines which elements to
/// export based on visibility settings for the view. It does not control
/// what geometry is exported for the element.</remarks>
public View FilterViewForExport
{
get;
set;
}
/// <summary>
/// Determines how to generate space volumes on export. True means that we use the 2D room boundary and extrude it upwards based
/// on the room height. This is the method used in 2x2 and by user option. False means using the room geometry. The user option
/// is needed for certain governmental requirements, such as in Korea for non-residental buildings.
/// </summary>
public bool Use2DRoomBoundaryForRoomVolumeCreation
{
get;
set;
}
/// <summary>
/// Contains options for controlling how IFC GUIDs are generated on export.
/// </summary>
public GUIDOptions GUIDOptions
{
get
{
if (m_GUIDOptions == null)
m_GUIDOptions = new GUIDOptions();
return m_GUIDOptions;
}
}
/// <summary>
/// Contains options for setting how entity names are generated.
/// </summary>
public NamingOptions NamingOptions
{
get;
set;
}
/// <summary>
/// The file format to export. Not used currently.
/// </summary>
// TODO: Connect this to the output file being written by the client.
public IFCFileFormat IFCFileFormat
{
get;
set;
}
/// <summary>
/// Select export Config Name from the UI
/// </summary>
public String SelectedConfigName
{
get;
set;
}
/// <summary>
/// Select export Config Name from the UI
/// </summary>
public String SelectedParametermappingTableName
{
get;
set;
}
/// <summary>
/// Allow exporting a mix of extrusions and BReps as a solid model, if possible.
/// </summary>
public bool CanExportSolidModelRep { get; set; }
/// <summary>
/// Specifies which phase id to export. May be expanded to phases.
/// </summary>
public ElementId ActivePhaseId
{
get;
protected set;
}
/// <summary>
/// The phase element corresponding to the phase id.
/// </summary>
public Phase ActivePhaseElement
{
get;
protected set;
}
///<summary>
/// The ExportingLink flag.
/// This stores the flag telling if the current export is for a linked document.
/// </summary>
public bool ExportingLink
{
get;
set;
}
private IList<Tuple<string, Transform>> m_LinkInstanceInfos = new List<Tuple<string, Transform>>();
/// <summary>
/// Get the number of RevitLinkInstance transforms for this export.
/// </summary>
/// <returns>The number of Revit Link Instance transforms for this export.</returns>
public int GetNumLinkInstanceInfos()
{
if (m_LinkInstanceInfos == null)
return 0;
return m_LinkInstanceInfos.Count;
}