SolidIntersectWithCurve Method |
Calculates and returns the intersection between a curve and this solid.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic SolidCurveIntersection IntersectWithCurve(
Curve curve,
SolidCurveIntersectionOptions options
)
Public Function IntersectWithCurve (
curve As Curve,
options As SolidCurveIntersectionOptions
) As SolidCurveIntersection
public:
SolidCurveIntersection^ IntersectWithCurve(
Curve^ curve,
SolidCurveIntersectionOptions^ options
)
member IntersectWithCurve :
curve : Curve *
options : SolidCurveIntersectionOptions -> SolidCurveIntersection
Parameters
- curve Curve
-
The curve.
- options SolidCurveIntersectionOptions
-
The options. If NULL, the default options will be used.
Return Value
SolidCurveIntersection
The intersection results.
Exceptions
Exampleprivate void FindColumnRebarIntersections(Document document, FamilyInstance column)
{
double totalRebarLengthInColumn = 0;
RebarHostData rebarHostData = RebarHostData.GetRebarHostData(column);
if (rebarHostData == null)
{
return;
}
IList<Rebar> rebars = rebarHostData.GetRebarsInHost();
if (rebars.Count == 0)
{
return;
}
Options geomOptions = new Options();
geomOptions.ComputeReferences = true;
geomOptions.DetailLevel = ViewDetailLevel.Fine;
GeometryElement elemGeometry = column.get_Geometry(geomOptions);
foreach (GeometryObject elemPrimitive in elemGeometry)
{
GeometryInstance gInstance = elemPrimitive as GeometryInstance;
if (gInstance == null)
{
continue;
}
GeometryElement instGeometry = gInstance.GetInstanceGeometry();
foreach (GeometryObject instPrimitive in instGeometry)
{
Solid solid = instPrimitive as Solid;
if (solid == null)
{
continue;
}
SolidCurveIntersectionOptions intersectOptions = new SolidCurveIntersectionOptions();
foreach (Rebar rebar in rebars)
{
bool selfIntersection = false;
bool suppresHooks = false;
bool suppresBends = false;
IList<Curve> curves = rebar.GetCenterlineCurves(selfIntersection, suppresHooks, suppresBends, MultiplanarOption.IncludeOnlyPlanarCurves, 0);
foreach (Curve curve in curves)
{
SolidCurveIntersection intersection = solid.IntersectWithCurve(curve, intersectOptions);
for (int segment = 0; segment <= intersection.SegmentCount - 1; segment++)
{
Curve curveInside = intersection.GetCurveSegment(segment);
double rebarLengthInColumn = curveInside.Length;
totalRebarLengthInColumn = totalRebarLengthInColumn + rebarLengthInColumn;
}
}
}
}
}
}
Private Sub FindColumnRebarIntersections(document As Document, column As FamilyInstance)
Dim totalRebarLengthInColumn As Double = 0
Dim rebarHostData__1 As RebarHostData = RebarHostData.GetRebarHostData(column)
If rebarHostData__1 Is Nothing Then
Return
End If
Dim rebars As IList(Of Rebar) = rebarHostData__1.GetRebarsInHost()
If rebars.Count = 0 Then
Return
End If
Dim geomOptions As New Options()
geomOptions.ComputeReferences = True
geomOptions.DetailLevel = ViewDetailLevel.Fine
Dim elemGeometry As GeometryElement = column.Geometry(geomOptions)
For Each elemPrimitive As GeometryObject In elemGeometry
Dim gInstance As GeometryInstance = TryCast(elemPrimitive, GeometryInstance)
If gInstance Is Nothing Then
Continue For
End If
Dim instGeometry As GeometryElement = gInstance.GetInstanceGeometry()
For Each instPrimitive As GeometryObject In instGeometry
Dim solid As Solid = TryCast(instPrimitive, Solid)
If solid Is Nothing Then
Continue For
End If
Dim intersectOptions As New SolidCurveIntersectionOptions()
For Each rebar As Rebar In rebars
Dim selfIntersection As Boolean = False
Dim suppresHooks As Boolean = False
Dim suppresBends As Boolean = False
Dim curves As IList(Of Curve) = rebar.GetCenterlineCurves(selfIntersection, suppresHooks, suppresBends, MultiplanarOption.IncludeOnlyPlanarCurves, 0)
For Each curve As Curve In curves
Dim intersection As SolidCurveIntersection = solid.IntersectWithCurve(curve, intersectOptions)
For segment As Integer = 0 To intersection.SegmentCount - 1
Dim curveInside As Curve = intersection.GetCurveSegment(segment)
Dim rebarLengthInColumn As Double = curveInside.Length
totalRebarLengthInColumn = totalRebarLengthInColumn + rebarLengthInColumn
Next
Next
Next
Next
Next
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also