/// <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); } }