Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Intersect solid and plane

3 REPLIES 3
Reply
Message 1 of 4
sonicer
2543 Views, 3 Replies

Intersect solid and plane

How can I get the curve that is result from intersect solid and plane?

 

I am using this:

   Plane plane =  new Plane(XYZ.BasisZ,point);                                                        
   Solid cast = BooleanOperationsUtils.CutWithHalfSpace(solid, plane); 

But don't know is the right way....?

 

thx..

 

3 REPLIES 3
Message 2 of 4
FAIR59
in reply to: sonicer

from the resulting solid (cast) find the face with normal (0,0,-1). The edges are the required curve(s)

 

                SketchPlane skPlane = SketchPlane.Create(document, plane);
                Solid cast = BooleanOperationsUtils.CutWithHalfSpace(solid, plane);
                PlanarFace CutFace = null;

                foreach (Face face in cast.Faces)
                {
                    PlanarFace planFace = face as PlanarFace;
                    if (planFace == null) continue;
                    if (planFace.FaceNormal.IsAlmostEqualTo(XYZ.BasisZ.Negate()) && planFace.Origin.Z == point.Z)
                    {
                        CutFace = planFace;
                    }
                }
                if (CutFace == null) return Result.Failed;
                CurveLoop _boundery = CutFace.GetEdgesAsCurveLoops().First();
                foreach (Curve c in _boundery)
                {
                    document.FamilyCreate.NewModelCurve(c, skPlane);
                }
Message 3 of 4
Revitalizer
in reply to: FAIR59

Hi FAIR59,

 

I think that there may be more than a single Face in the result.

E.g. if cutting an "O" shaped solid into a half, making a "C", there will be two intersection faces on the "C"'s endings.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 4
FAIR59
in reply to: Revitalizer

Hi Revitalizer,

 

you're right. To find all the curves in the plane, you need to make a list of faces that pass the test, instead of the single CutFace.

And of course you'd need to process every Curveloop in the FoundFace.GetEdgesAsCurveLoops(), instead of only the first.  

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community