/// <summary>
        /// This node will select grids along a model curve element ordered based on the start of the model curve.
        /// This works in the active view. So whatever plan representation your grids have, that is what is used.
        /// </summary>
        /// <param name="modelCurve">Revit model curve to select grids along.</param>
        /// <returns name="orderedGrids">The intersecting grids ordered from beginning to end of the line.</returns>
        public static List <global::Revit.Elements.Grid> IntersectingGridsByModelCurve(global::Revit.Elements.ModelCurve modelCurve)
        {
            ModelCurve mCurve = modelCurve.InternalElement as ModelCurve;

            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;

            List <global::Revit.Elements.Grid> intersectingGrids = new List <global::Revit.Elements.Grid>();

            IList <Autodesk.Revit.DB.Element> grids = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Grids).WhereElementIsNotElementType().ToElements();

            foreach (var grid in grids)
            {
                Grid  g  = grid as Grid;
                Curve c  = g.GetCurvesInView(DatumExtentType.ViewSpecific, doc.ActiveView).First();
                Curve c2 = mCurve.GeometryCurve;

                Point pt1 = Point.ByCoordinates(0, 0, c.GetEndPoint(0).Z);
                Point pt2 = Point.ByCoordinates(0, 0, c2.GetEndPoint(0).Z);
                XYZ   vec = Vector.ByTwoPoints(pt2, pt1).ToRevitType();

                var transformed = c2.CreateTransformed(Transform.CreateTranslation(vec));

                SetComparisonResult test = c.Intersect(transformed);

                if (test == SetComparisonResult.Overlap ||
                    test == SetComparisonResult.Subset ||
                    test == SetComparisonResult.Superset ||
                    test == SetComparisonResult.Equal)
                {
                    intersectingGrids.Add(g.ToDSType(true) as global::Revit.Elements.Grid);
                }
            }

            return(intersectingGrids.OrderBy(g => g.Curve.DistanceTo(modelCurve.Curve.StartPoint)).ToList());
        }
示例#2
0
        static RevSurface FromRevolvedSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, DB.Curve curve, DB.BoundingBoxUV bboxUV, double relativeTolerance)
        {
            var atol = relativeTolerance * Revit.AngleTolerance;
            var ctol = relativeTolerance * Revit.ShortCurveTolerance;
            var uu   = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol);

            var plane = new Plane
                        (
                AsPoint3d(origin),
                AsVector3d(xDir),
                AsVector3d(yDir)
                        );
            var axisDir = AsVector3d(zDir);

            using (var ECStoWCS = new DB.Transform(DB.Transform.Identity)
            {
                Origin = origin, BasisX = xDir.Normalize(), BasisY = yDir.Normalize(), BasisZ = zDir.Normalize()
            })
            {
                var c = ToRhino(curve.CreateTransformed(ECStoWCS));
                c = ctol == 0.0 ? c : c.Extend(CurveEnd.Both, ctol, CurveExtensionStyle.Smooth);

                var axis = new Line(plane.Origin, plane.Normal);
                return(RevSurface.Create(c, axis, uu.Min, uu.Max));
            }
        }
示例#3
0
        static RevSurface FromRevolvedSurface(DB.XYZ origin, DB.XYZ xDir, DB.XYZ yDir, DB.XYZ zDir, DB.Curve curve, DB.BoundingBoxUV bboxUV)
        {
            var ctol = Revit.ShortCurveTolerance;
            var atol = Revit.AngleTolerance;
            var uu   = new Interval(bboxUV.Min.U - atol, bboxUV.Max.U + atol);

            var o = origin.ToRhino();
            var z = (Vector3d)zDir.Normalize().ToRhino();

            var axis = new Line(o, o + z);

            using (var ECStoWCS = new DB.Transform(DB.Transform.Identity)
            {
                Origin = origin, BasisX = xDir.Normalize(), BasisY = yDir.Normalize(), BasisZ = zDir.Normalize()
            })
            {
                var c = curve.CreateTransformed(ECStoWCS).ToRhino().Extend(CurveEnd.Both, ctol, CurveExtensionStyle.Smooth);
                return(RevSurface.Create(c, axis, uu.Min, uu.Max));
            }
        }