/// <summary> /// Creates a Revit material based on the information contained in this class. /// </summary> /// <param name="doc">The document.</param> public void Create(Document doc) { // TODO: support cut pattern id and cut pattern color. try { string name = Name; if (string.IsNullOrEmpty(name)) { name = String.Format(Resources.IFCDefaultMaterialName, Id); } if (m_CreatedElementId == ElementId.InvalidElementId && IsValidForCreation) { IFCSurfaceStyle surfaceStyle = GetSurfaceStyle(); if (surfaceStyle != null) { m_CreatedElementId = surfaceStyle.Create(doc, name, null, Id); } else { IFCMaterialInfo materialInfo = IFCMaterialInfo.Create(null, null, null, null, ElementId.InvalidElementId); m_CreatedElementId = CreateMaterialElem(doc, Id, Name, materialInfo); } } else { IsValidForCreation = false; } } catch (Exception ex) { IsValidForCreation = false; Importer.TheLog.LogCreationError(this, ex.Message, false); } }
/// <summary> /// Create the Revit elements associated with this IfcPresentationLayerWithStyle. /// </summary> /// <param name="shapeEditScope">The shape edit scope.</param> override public void Create(IFCImportShapeEditScope shapeEditScope) { // TODO: support cut pattern id and cut pattern color. if (CreatedMaterialElementId != ElementId.InvalidElementId || !IsValidForCreation) { return; } base.Create(shapeEditScope); try { // If the styled item or the surface style has a name, use it. IFCSurfaceStyle surfaceStyle = GetSurfaceStyle(); if (surfaceStyle == null) { // We only handle surface styles at the moment; log file should already reflect any other unhandled styles. IsValidForCreation = true; return; } string forcedName = surfaceStyle.Name; if (string.IsNullOrWhiteSpace(forcedName)) { forcedName = Name; } CreatedMaterialElementId = surfaceStyle.Create(shapeEditScope.Document, forcedName, null, Id); } catch (Exception ex) { IsValidForCreation = false; Importer.TheLog.LogCreationError(this, ex.Message, false); } }
/// <summary> /// Processes an IfcSurfaceStyle entity handle. /// </summary> /// <param name="ifcSurfaceStyle">The IfcSurfaceStyle handle.</param> /// <returns>The IFCSurfaceStyle object.</returns> public static IFCSurfaceStyle ProcessIFCSurfaceStyle(IFCAnyHandle ifcSurfaceStyle) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcSurfaceStyle)) { Importer.TheLog.LogNullError(IFCEntityType.IfcSurfaceStyle); return(null); } IFCEntity surfaceStyle; if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcSurfaceStyle.StepId, out surfaceStyle)) { surfaceStyle = new IFCSurfaceStyle(ifcSurfaceStyle); } return(surfaceStyle as IFCSurfaceStyle); }
/// <summary> /// Processes an IfcPresentationStyle entity handle. /// </summary> /// <param name="ifcPresentationStyle">The IfcPresentationStyle handle.</param> /// <returns>The IFCPresentationStyle object.</returns> public static IFCPresentationStyle ProcessIFCPresentationStyle(IFCAnyHandle ifcPresentationStyle) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcPresentationStyle)) { Importer.TheLog.LogNullError(IFCEntityType.IfcPresentationStyle); return null; } IFCEntity presentationStyle; if (IFCImportFile.TheFile.EntityMap.TryGetValue(ifcPresentationStyle.StepId, out presentationStyle)) return (presentationStyle as IFCPresentationStyle); if (IFCAnyHandleUtil.IsSubTypeOf(ifcPresentationStyle, IFCEntityType.IfcSurfaceStyle)) return IFCSurfaceStyle.ProcessIFCSurfaceStyle(ifcPresentationStyle); Importer.TheLog.LogUnhandledSubTypeError(ifcPresentationStyle, "IfcPresentationStyle", false); return null; }
/// <summary> /// Processes an IfcSurfaceStyle entity handle. /// </summary> /// <param name="ifcSurfaceStyle">The IfcSurfaceStyle handle.</param> /// <returns>The IFCSurfaceStyle object.</returns> public static IFCSurfaceStyle ProcessIFCSurfaceStyle(IFCAnyHandle ifcSurfaceStyle) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcSurfaceStyle)) { Importer.TheLog.LogNullError(IFCEntityType.IfcSurfaceStyle); return null; } IFCEntity surfaceStyle; if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcSurfaceStyle.StepId, out surfaceStyle)) surfaceStyle = new IFCSurfaceStyle(ifcSurfaceStyle); return (surfaceStyle as IFCSurfaceStyle); }