要素を鏡像化する

要素を鏡像化する

ElementTransformUtils クラスは、2 つの静的メソッドを提供して、プロジェクトの 1 つまたは複数の要素を鏡像化します。

表 21: 鏡像化メソッド

メンバー

説明

MirrorElement(Document, ElementId, Plane)

ジオメトリ面に対して 1 つの要素を鏡像化します。

MirrorElements(Document, ICollection<ElementId>, Plane)

ジオメトリ面に対して複数の要素を鏡像化します。

鏡像化操作を実行した後は、ElementSet の選択から新しい要素にアクセスすることができます。

ElementTransformUtils.CanMirrorElement()と ElementTransformUtils.CanMirrorElements()を使用すると、要素の鏡像化を試みる前に、1 つまたは複数の要素の鏡像化が可能かどうかを判断することができます。

次のコードは、壁の側面に基づいて計算された面を使用して壁を鏡像化する方法を示します。

コード領域 10-8: 壁を鏡像化

public void MirrorWall(Autodesk.Revit.DB.Document document, Wall wall)
{
        Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First();

        // get one of the wall's major side faces
        Face face = wall.GetGeometryObjectFromReference(reference) as Face; 

        UV bboxMin = face.GetBoundingBox().Min;
        // create a plane based on this side face with an offset of 10 in the X & Y directions
 
        Plane plane = new Plane(face.ComputeNormal(bboxMin), 
                face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0)));
 
        ElementTransformUtils.MirrorElement(document, wall.Id, plane);
}

それぞれの FamilyInstance が Mirrored プロパティを持ちます。これは、FamilyInstance (柱など)が鏡像化されたものかどうかを示します。