/// <summary> /// Create a simplified copy of a IFCFeatureElement, intended explicitly for the purpose of voiding a particular IFCElement. /// </summary> /// <param name="original">The IFCFeatureElement we are partially copying.</param> /// <param name="parentEntity">The IFCElement we are voiding.</param> /// <returns>A new IFCFeatureElement that is a minimal copy of original with influence by parentEntity.</returns> public static IFCFeatureElement CreateOpeningClone(IFCFeatureElement original, IFCElement parentEntity) { IFCFeatureElement clone = new IFCFeatureElement(); // Note that the GlobalId is left to null here; this allows us to later decide not to create a DirectShape for the result. // Get the ObjectLocation and ProductRepresentation from the original entity, which is all we need to create geometry. clone.ObjectLocation = original.ObjectLocation; clone.ProductRepresentation = original.ProductRepresentation; // Get the EntityType and ShapeType from the parent to ensure that it "matches" the category and graphics style of the parent. clone.EntityType = parentEntity.EntityType; clone.ShapeType = parentEntity.ShapeType; // Copy the material of the parent entity to try to match the color of the opening faces. // This will work nicely if the parent entity is one material. IFCMaterial parentMaterial = parentEntity.GetTheMaterial(); if (parentMaterial != null) { clone.MaterialSelect = parentMaterial; } return(clone); }
/// <summary> /// Processes an IfcElement object. /// </summary> /// <param name="ifcElement">The IfcElement handle.</param> /// <returns>The IFCElement object.</returns> public static IFCElement ProcessIFCElement(IFCAnyHandle ifcElement) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcElement)) { IFCImportFile.TheLog.LogNullError(IFCEntityType.IfcElement); return(null); } IFCEntity cachedIFCElement; IFCImportFile.TheFile.EntityMap.TryGetValue(ifcElement.StepId, out cachedIFCElement); if (cachedIFCElement != null) { return(cachedIFCElement as IFCElement); } IFCElement newIFCElement = null; // other subclasses not handled yet! if (IFCAnyHandleUtil.IsSubTypeOf(ifcElement, IFCEntityType.IfcFeatureElement)) { newIFCElement = IFCFeatureElement.ProcessIFCFeatureElement(ifcElement); } else { newIFCElement = new IFCElement(ifcElement); } return(newIFCElement); }
/// <summary> /// Creates or populates Revit elements based on the information contained in this class. /// </summary> /// <param name="doc">The document.</param> protected override void Create(Document doc) { foreach (IFCFeatureElement opening in Openings) { try { // Create the actual Revit element based on the IFCFeatureElement here. CreateElement(doc, opening); // This gets around the issue that the Boolean operation between the void(s) in the IFCFeatureElement and // the solid(s) in the IFCElement may use the Graphics Style of the voids in the resulting Solid(s), meaning // that some faces may disappear when we turn off the visibility of IfcOpeningElements. IFCFeatureElement openingClone = IFCFeatureElement.CreateOpeningClone(opening, this); CreateElement(doc, openingClone); foreach (IFCSolidInfo voidGeom in openingClone.Solids) { Voids.Add(voidGeom); } } catch (Exception ex) { IFCImportFile.TheLog.LogError(opening.Id, ex.Message, false); } } base.Create(doc); }
/// <summary> /// Processes an IfcElement object. /// </summary> /// <param name="ifcElement">The IfcElement handle.</param> /// <returns>The IFCElement object.</returns> public static IFCElement ProcessIFCElement(IFCAnyHandle ifcElement) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcElement)) { Importer.TheLog.LogNullError(IFCEntityType.IfcElement); return(null); } try { IFCEntity cachedIFCElement; IFCImportFile.TheFile.EntityMap.TryGetValue(ifcElement.StepId, out cachedIFCElement); if (cachedIFCElement != null) { return(cachedIFCElement as IFCElement); } // other subclasses not handled yet. if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcElement, IFCEntityType.IfcBuildingElement)) { return(IFCBuildingElement.ProcessIFCBuildingElement(ifcElement)); } if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcElement, IFCEntityType.IfcFeatureElement)) { return(IFCFeatureElement.ProcessIFCFeatureElement(ifcElement)); } if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcElement, IFCEntityType.IfcElementAssembly)) { return(IFCElementAssembly.ProcessIFCElementAssembly(ifcElement)); } if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcElement, IFCEntityType.IfcElementComponent)) { return(IFCElementComponent.ProcessIFCElementComponent(ifcElement)); } return(new IFCElement(ifcElement)); } catch (Exception ex) { HandleError(ex.Message, ifcElement, true); return(null); } }
/// <summary> /// Create a simplified copy of a IFCFeatureElement, intended explicitly for the purpose of voiding a particular IFCElement. /// </summary> /// <param name="original">The IFCFeatureElement we are partially copying.</param> /// <param name="parentEntity">The IFCElement we are voiding.</param> /// <returns>A new IFCFeatureElement that is a minimal copy of original with influence by parentEntity.</returns> public static IFCFeatureElement CreateOpeningClone(IFCFeatureElement original, IFCElement parentEntity) { IFCFeatureElement clone = new IFCFeatureElement(); // Note that the GlobalId is left to null here; this allows us to later decide not to create a DirectShape for the result. // Get the ObjectLocation and ProductRepresentation from the original entity, which is all we need to create geometry. clone.ObjectLocation = original.ObjectLocation; clone.ProductRepresentation = original.ProductRepresentation; // Get the EntityType and ShapeType from the parent to ensure that it "matches" the category and graphics style of the parent. clone.EntityType = parentEntity.EntityType; clone.ShapeType = parentEntity.ShapeType; // Copy the material of the parent entity to try to match the color of the opening faces. // This will work nicely if the parent entity is one material. IFCMaterial parentMaterial = parentEntity.GetTheMaterial(); if (parentMaterial != null) clone.MaterialSelect = parentMaterial; return clone; }