Пример #1
0
        private static Curve CreateReversed(Curve curve)
        {
            Autodesk.Revit.DB.Curve orig = curve.ToRevitType();
            var app = DocumentManager.Instance.CurrentUIApplication;

            if (orig is Line)
            {
                var line = Line.CreateBound(
                    orig.GetEndPoint(1),
                    orig.GetEndPoint(0));
                return(line.ToProtoType());
            }
            else if (orig is Arc)
            {
                var arc = Arc.Create(orig.GetEndPoint(1),
                                     orig.GetEndPoint(0),
                                     orig.Evaluate(0.5, true));
                return(arc.ToProtoType());
            }
            else
            {
                throw new Exception(
                          "CreateReversedCurve - Unreachable");
            }
        }
Пример #2
0
        private static List <Point> GetPoints(Autodesk.Revit.DB.Curve curve)
        {
            var curves = new List <Point>();

            switch (curve)
            {
            case Autodesk.Revit.DB.Line line:
                curves.Add(line.GetEndPoint(0).ToPoint());
                break;

            case Autodesk.Revit.DB.Arc arc:
                curves.Add(arc.Evaluate(0, true).ToPoint());
                curves.Add(arc.Evaluate(0.25, true).ToPoint());
                curves.Add(arc.Evaluate(0.5, true).ToPoint());
                curves.Add(arc.Evaluate(0.75, true).ToPoint());
                break;

            case Autodesk.Revit.DB.CylindricalHelix unused:
            case Autodesk.Revit.DB.Ellipse unused1:
            case Autodesk.Revit.DB.HermiteSpline unused2:
            case Autodesk.Revit.DB.NurbSpline unused3:
                break;
            }

            return(curves);
        }
Пример #3
0
        private static Autodesk.Revit.DB.Face FindFace(IEnumerable faces, Autodesk.Revit.DB.SpatialElementGeometryResults result, Autodesk.Revit.DB.Curve bCurve)
        {
            foreach (Autodesk.Revit.DB.Face f in faces)
            {
                var boundaryFaces = result.GetBoundaryFaceInfo(f).FirstOrDefault();
                if (boundaryFaces != null && (boundaryFaces.SubfaceType == Autodesk.Revit.DB.SubfaceType.Top ||
                                              boundaryFaces.SubfaceType == Autodesk.Revit.DB.SubfaceType.Bottom))
                {
                    continue; // face is either Top/Bottom so we can skip
                }

                var normal = f.ComputeNormal(new Autodesk.Revit.DB.UV(0.5, 0.5));
                if (normal.IsAlmostEqualTo(Autodesk.Revit.DB.XYZ.BasisZ) || normal.IsAlmostEqualTo(Autodesk.Revit.DB.XYZ.BasisZ.Negate()))
                {
                    continue;                                    // face is either Top/Bottom so we can skip
                }
                var edges = f.GetEdgesAsCurveLoops().First();    // first loop is outer boundary
                if (!edges.Any(x => x.OverlapsWithIn2D(bCurve))) // room's face might be off the floor/level above or offset. if XY matches, we are good.
                {
                    continue;                                    // none of the edges of that face match our curve so we can skip
                }
                return(f);
            }

            return(null);
        }