ModelCurve プロジェクトのモデル線分を表します。3D 空間に存在し、すべてのビューに表示されます。
次の図は、4 つの ModelCurve 派生クラスを示します。
図 92: ModelLine と ModelArc
図 93: ModelEllipse と ModelNurbSpline
ModelCurve を作成するためには、曲線が配置されている場所に Geometry.Curve と SketchPlane を作成することが重要です。入力した Geometry.Curve タイプに基づき、対応する戻り値の ModelCurve を適切なタイプにダウンキャストすることができます。
次の例は、新しいモデル曲線(ModelLine と ModelArc)を作成する方法を示します。
コード領域 17-2: 新しいモデル曲線を作成 |
// get handle to application from document Autodesk.Revit.ApplicationServices.Application application = document.Application; // Create a geometry line in Revit application XYZ startPoint = new XYZ(0, 0, 0); XYZ endPoint = new XYZ(10, 10, 0); Line geomLine = Line.CreateBound(startPoint, endPoint); // Create a geometry arc in Revit application XYZ end0 = new XYZ(1, 0, 0); XYZ end1 = new XYZ(10, 10, 10); XYZ pointOnCurve = new XYZ(10, 0, 0); Arc geomArc = Arc.Create(end0, end1, pointOnCurve); // Create a geometry plane in Revit application XYZ origin = new XYZ(0, 0, 0); XYZ normal = new XYZ(1, 1, 0); Plane geomPlane = application.Create.NewPlane(normal, origin); // Create a sketch plane in current document SketchPlane sketch = SketchPlane.Create(document, geomPlane); // Create a ModelLine element using the created geometry line and sketch plane ModelLine line = document.Create.NewModelCurve(geomLine, sketch) as ModelLine; // Create a ModelArc element using the created geometry arc and sketch plane ModelArc arc = document.Cree.NewModelCurve(geomArc, sketch) as ModelArc; |
GeometryCurve
GeometryCurve プロパティは、曲線のジオメトリ曲線を取得、設定するために使用します。ModelHermiteSpline を除き、次の 4 つの ModelCurves からは異なる Geometry.Curves を取得することができます。
次のコード サンプルは、ModelCurve から特定の曲線を取得する方法を説明しています。
コード領域 17-3: ModelCurve から特定の曲線を取得 |
//get the geometry modelCurve of the model modelCurve Autodesk.Revit.DB.Curve geoCurve = modelCurve.GeometryCurve; if (geoCurve is Autodesk.Revit.DB.Line) { Line geoLine = geoCurve as Line; } |
GeometryCurve プロパティの戻り値は一般的な Geometry.Curve オブジェクトであるため、オブジェクト タイプを変更するには as 演算子を使用する必要があります。
線種は、GraphicsStyle クラスによって表されます。ModelCurve のすべての線種は、GraphicsStyle 要素の一連の ElementIds を返す GetLineStyleIds()メソッドから使用することができます。