要素の面をペイントする

要素の面をペイントする

[ペイント]ツールの機能は Revit API を通じて利用できます。壁、床、屋根などの要素の面にマテリアルをペイントすることで外観を変更することができます。この場合、要素の構造は変更されません。

要素のペイントに関連するメソッドは Document クラスの一部です。Document.Paint()は要素の指定した面にマテリアルを適用します。Document.RemovePaint()は適用されたマテリアルを削除します。さらに、IsPainted()メソッドと GetPaintedMaterial()メソッドは要素の面に関する情報を返します。

コード領域: 壁の面をペイント

// Paint any unpainted faces of a given wall
public void PaintWallFaces(Wall wall, ElementId matId)
{
    Document doc = wall.Document;
    GeometryElement geometryElement = wall.get_Geometry(new Options());
    foreach (GeometryObject geometryObject in geometryElement)
    {
        if (geometryObject is Solid)
        {
            Solid solid = geometryObject as Solid;
            foreach (Face face in solid.Faces)
            {
                if (doc.IsPainted(wall.Id, face) == false)
                {
                    doc.Paint(wall.Id, face, matId);
                }
            }
        }
    }
}