/// <summary> /// Create a copying of the geometry of an entity with a different graphics style. /// </summary> /// <param name="doc">The document.</param> /// <param name="original">The IFCProduct we are partially copying.</param> /// <param name="parentEntity">The IFCObjectDefinition we are going to add the geometry to.</param> /// <param name="cloneParentMaterial">Determine whether to use the one material of the parent entity, if it exists and is unique.</param> /// <returns>The list of geometries created with a new category and possibly material.</returns> public static IList <IFCSolidInfo> CloneElementGeometry(Document doc, IFCProduct original, IFCObjectDefinition parentEntity, bool cloneParentMaterial) { using (TemporaryDisableLogging disableLogging = new TemporaryDisableLogging()) { IFCElement clone = new IFCElement(); // 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; clone.MaterialSelect = original.MaterialSelect; // Get the EntityType and PredefinedType from the parent to ensure that it "matches" the category and graphics style of the parent. clone.EntityType = parentEntity.EntityType; clone.PredefinedType = parentEntity.PredefinedType; if (cloneParentMaterial) { // This will only work if the parent entity has one material. IFCMaterial parentMaterial = parentEntity.GetTheMaterial(); if (parentMaterial != null) { clone.MaterialSelect = parentMaterial; } } IList <GeometryObject> geomObjs = new List <GeometryObject>(); CreateElement(doc, clone); return(clone.Solids); } }
/// <summary> /// Create a copying of the geometry of an entity with a different graphics style. /// </summary> /// <param name="doc">The document.</param> /// <param name="original">The IFCProduct we are partially copying.</param> /// <param name="parentEntity">The IFCObjectDefinition we are going to add the geometry to.</param> /// <param name="cloneParentMaterial">Determine whether to use the one material of the parent entity, if it exists and is unique.</param> /// <returns>The list of geometries created with a new category and possibly material.</returns> public static IList<IFCSolidInfo> CloneElementGeometry(Document doc, IFCProduct original, IFCObjectDefinition parentEntity, bool cloneParentMaterial) { using (TemporaryDisableLogging disableLogging = new TemporaryDisableLogging()) { IFCElement clone = new IFCElement(); // 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; clone.MaterialSelect = original.MaterialSelect; // Get the EntityType and PredefinedType from the parent to ensure that it "matches" the category and graphics style of the parent. clone.EntityType = parentEntity.EntityType; clone.PredefinedType = parentEntity.PredefinedType; if (cloneParentMaterial) { // This will only work if the parent entity has one material. IFCMaterial parentMaterial = parentEntity.GetTheMaterial(); if (parentMaterial != null) clone.MaterialSelect = parentMaterial; } IList<GeometryObject> geomObjs = new List<GeometryObject>(); CreateElement(doc, clone); return clone.Solids; } }