メソッド Solid.IntersectWithCurve()は、閉じたソリッド ボリュームと曲線の交点を計算します。SolidCurveIntersectionOptions クラスは、IntersectWithCurve()メソッドからの結果にソリッド ボリュームの内側または外側の曲線セグメントが含まれるかどうかを指定できます。ソリッドの内側の曲線セグメントには、ソリッドの面と一致する曲線セグメントが含まれます。曲線セグメントとセグメントのパラメータの両方が結果で使用できます。
次の例では、IntersectWithCurve()メソッドを使用して、列にある鉄筋の長さを計算します。
|
コード領域: ソリッドと曲線の交点を検出 |
void FindColumnRebarIntersections(Document document, FamilyInstance column)
{
// Find rebar hosted by this column
RebarHostData rebarHostData = RebarHostData.GetRebarHostData(column);
if (null != rebarHostData)
{
IList<Rebar> rebars = rebarHostData.GetRebarsInHost();
if (rebars.Count > 0)
{
Options geomOptions = new Options();
geomOptions.ComputeReferences = true;
geomOptions.DetailLevel = ViewDetailLevel.Fine;
GeometryElement geomElement = column.get_Geometry(geomOptions);
foreach (GeometryObject geomObj in geomElement)
{
GeometryInstance geomInst = geomObj as GeometryInstance;
if (null != geomInst)
{
GeometryElement columnGeometry = geomInst.GetInstanceGeometry();
foreach (GeometryObject obj in columnGeometry)
{
Solid solid = obj as Solid;
if (null != solid)
{
SolidCurveIntersectionOptions options = new SolidCurveIntersectionOptions();
foreach (Rebar rebar in rebars)
{
// Get the centerlines for the rebar to find their intersection with the collumn
IList<Curve> curves = rebar.GetCenterlineCurves(false, false, false);
foreach (Curve curve in curves)
{
SolidCurveIntersection intersection = solid.IntersectWithCurve(curve, options);
for (int n = 0; n < intersection.SegmentCount; n++)
{
// calculate length of rebar that is inside the column
Curve curveInside = intersection.GetCurveSegment(n);
double rebarLengthinColumn = curveInside.Length;
}
}
}
}
}
}
}
}
}
}
|