override protected void Process(IFCAnyHandle item) { base.Process(item); SurfaceSide = IFCEnums.GetSafeEnumerationAttribute<IFCSurfaceSide>(item, "Side", IFCSurfaceSide.Both); HashSet<IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute<HashSet<IFCAnyHandle>>(item, "Styles"); if (styles == null || styles.Count == 0) Importer.TheLog.LogError(item.StepId, "No style information found, ignoring.", true); foreach (IFCAnyHandle style in styles) { try { if (IFCAnyHandleUtil.IsSubTypeOf(style, IFCEntityType.IfcSurfaceStyleShading)) { if (ShadingStyle == null) ShadingStyle = IFCSurfaceStyleShading.ProcessIFCSurfaceStyleShading(style); else Importer.TheLog.LogWarning(item.StepId, "Duplicate IfcSurfaceStyleShading, ignoring.", false); } else Importer.TheLog.LogUnhandledSubTypeError(style, "IfcSurfaceStyleElementSelect", false); } catch (Exception ex) { Importer.TheLog.LogError(style.StepId, ex.Message, false); } } }
override protected void Process(IFCAnyHandle item) { base.Process(item); string surfaceSideAsString = IFCAnyHandleUtil.GetEnumerationAttribute(item, "Side"); if (surfaceSideAsString == null) { SurfaceSide = IFCSurfaceSide.Both; IFCImportFile.TheLog.LogWarning(item.StepId, "No surface side defined, defaulting to Both.", false); } else { SurfaceSide = (IFCSurfaceSide)Enum.Parse(typeof(IFCSurfaceSide), surfaceSideAsString, true); } HashSet <IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(item, "Styles"); if (styles == null || styles.Count == 0) { IFCImportFile.TheLog.LogError(item.StepId, "No style information found, ignoring.", true); } foreach (IFCAnyHandle style in styles) { try { if (IFCAnyHandleUtil.IsSubTypeOf(style, IFCEntityType.IfcSurfaceStyleShading)) { if (ShadingStyle == null) { ShadingStyle = IFCSurfaceStyleShading.ProcessIFCSurfaceStyleShading(style); } else { IFCImportFile.TheLog.LogWarning(item.StepId, "Duplicate IfcSurfaceStyleShading, ignoring.", false); } } else { IFCImportFile.TheLog.LogUnhandledSubTypeError(style, "IfcSurfaceStyleElementSelect", false); } } catch (Exception ex) { IFCImportFile.TheLog.LogError(style.StepId, ex.Message, false); } } }
public static IFCAnyHandle GetOrCreateMaterialStyle(Document document, ExporterIFC exporterIFC, ElementId materialId) { IFCAnyHandle styleHnd = ExporterCacheManager.MaterialIdToStyleHandleCache.Find(materialId); if (styleHnd == null) { Material material = document.GetElement(materialId) as Material; if (material == null) { return(null); } string matName = material.Name; Color color = material.Color; double blueVal = color.Blue / 255.0; double greenVal = color.Green / 255.0; double redVal = color.Red / 255.0; IFCFile file = exporterIFC.GetFile(); IFCAnyHandle colorHnd = IFCInstanceExporter.CreateColourRgb(file, null, redVal, greenVal, blueVal); double transparency = ((double)material.Transparency) / 100.0; IFCData smoothness = IFCDataUtil.CreateAsNormalisedRatioMeasure(((double)material.Smoothness) / 100.0); IFCData specularExp = IFCDataUtil.CreateAsSpecularExponent(material.Shininess); IFCReflectanceMethod method = IFCReflectanceMethod.NotDefined; IFCAnyHandle renderingHnd = IFCInstanceExporter.CreateSurfaceStyleRendering(file, colorHnd, transparency, null, null, null, null, smoothness, specularExp, method); ICollection <IFCAnyHandle> surfStyles = new HashSet <IFCAnyHandle>(); surfStyles.Add(renderingHnd); IFCSurfaceSide surfSide = IFCSurfaceSide.Both; styleHnd = IFCInstanceExporter.CreateSurfaceStyle(file, matName, surfSide, surfStyles); ExporterCacheManager.MaterialIdToStyleHandleCache.Register(materialId, styleHnd); } return(styleHnd); }
override protected void Process(IFCAnyHandle item) { base.Process(item); SurfaceSide = IFCEnums.GetSafeEnumerationAttribute <IFCSurfaceSide>(item, "Side", IFCSurfaceSide.Both); HashSet <IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(item, "Styles"); if (styles == null || styles.Count == 0) { Importer.TheLog.LogError(item.StepId, "No style information found, ignoring.", true); } foreach (IFCAnyHandle style in styles) { try { if (IFCAnyHandleUtil.IsSubTypeOf(style, IFCEntityType.IfcSurfaceStyleShading)) { if (ShadingStyle == null) { ShadingStyle = IFCSurfaceStyleShading.ProcessIFCSurfaceStyleShading(style); } else { Importer.TheLog.LogWarning(item.StepId, "Duplicate IfcSurfaceStyleShading, ignoring.", false); } } else { Importer.TheLog.LogUnhandledSubTypeError(style, "IfcSurfaceStyleElementSelect", false); } } catch (Exception ex) { Importer.TheLog.LogError(style.StepId, ex.Message, false); } } }
override protected void Process(IFCAnyHandle item) { base.Process(item); string surfaceSideAsString = IFCAnyHandleUtil.GetEnumerationAttribute(item, "Side"); if (surfaceSideAsString == null) { SurfaceSide = IFCSurfaceSide.Both; IFCImportFile.TheLog.LogWarning(item.StepId, "No surface side defined, defaulting to Both.", false); } else SurfaceSide = (IFCSurfaceSide)Enum.Parse(typeof(IFCSurfaceSide), surfaceSideAsString, true); HashSet<IFCAnyHandle> styles = IFCAnyHandleUtil.GetAggregateInstanceAttribute<HashSet<IFCAnyHandle>>(item, "Styles"); if (styles == null || styles.Count == 0) IFCImportFile.TheLog.LogError(item.StepId, "No style information found, ignoring.", true); foreach (IFCAnyHandle style in styles) { try { if (IFCAnyHandleUtil.IsSubTypeOf(style, IFCEntityType.IfcSurfaceStyleShading)) { if (ShadingStyle == null) ShadingStyle = IFCSurfaceStyleShading.ProcessIFCSurfaceStyleShading(style); else IFCImportFile.TheLog.LogWarning(item.StepId, "Duplicate IfcSurfaceStyleShading, ignoring.", false); } else IFCImportFile.TheLog.LogUnhandledSubTypeError(style, "IfcSurfaceStyleElementSelect", false); } catch (Exception ex) { IFCImportFile.TheLog.LogError(style.StepId, ex.Message, false); } } }
/// <summary> /// Creates a handle representing an IfcSurfaceStyle and assigns it to the file. /// </summary> /// <param name="file">The file.</param> /// <param name="side">The side of the surface being used.</param> /// <param name="styles">The styles associated with the surface.</param> /// <returns>The handle.</returns> public static IFCAnyHandle CreateSurfaceStyle(IFCFile file, string name, IFCSurfaceSide side, ISet<IFCAnyHandle> styles) { IFCAnyHandleUtil.ValidateSubTypeOf(styles, false, IFCEntityType.IfcSurfaceStyleShading, IFCEntityType.IfcSurfaceStyleLighting, IFCEntityType.IfcSurfaceStyleRefraction, IFCEntityType.IfcSurfaceStyleWithTextures, IFCEntityType.IfcExternallyDefinedSurfaceStyle); IFCAnyHandle surfaceStyle = CreateInstance(file, IFCEntityType.IfcSurfaceStyle); SetPresentationStyle(surfaceStyle, name); IFCAnyHandleUtil.SetAttribute(surfaceStyle, "Side", side); IFCAnyHandleUtil.SetAttribute(surfaceStyle, "Styles", styles); return surfaceStyle; }