Ejemplo n.º 1
0
        public void ShrinkMultipleGrids()
        {
            UIDocument uidoc = this.ActiveUIDocument;
            Document   doc   = uidoc.Document;
            Selection  sel   = uidoc.Selection;
            View       view  = doc.ActiveView;
            var        num   = 3;

            #region Shrinking Grids using the Line - WIP
//			ISelectionFilter l = new JtElementsOfClassSelectionFilter<DetailCurve>();
//			Reference lineRef = uidoc.Selection.PickObject(ObjectType.Element, l, "Pick the grid extent");
//			LocationCurve crv = doc.GetElement(lineRef).Location as LocationCurve;
//			var cr = crv.Curve;
            #endregion

            // Get the Grids to extend from the project
            ISelectionFilter  f      = new JtElementsOfClassSelectionFilter <Grid>();
            IList <Reference> picked = sel.PickObjects(ObjectType.Element, f, "Pick Grids");

            foreach (var elemRef in picked)
            {
                Grid          grid       = doc.GetElement(elemRef) as Grid;
                IList <Curve> gridCurves = grid.GetCurvesInView(DatumExtentType.ViewSpecific, view);

                using (Transaction tx = new Transaction(doc))
                {
                    tx.Start("Modify the grids endpoints");
                    foreach (var c in gridCurves)
                    {
                        XYZ start = c.GetEndPoint(0);
                        XYZ end   = c.GetEndPoint(1);

                        XYZ  newStart = start.Add(num * XYZ.BasisX);
                        XYZ  newEnd   = end.Subtract(num * XYZ.BasisX);
                        Line newLine  = Line.CreateBound(newStart, newEnd);

                        grid.SetCurveInView(DatumExtentType.ViewSpecific, view, newLine);
                    }
                    tx.Commit();
                }
            }
            TaskDialog.Show("Result", "The Grids are extended");
        }
Ejemplo n.º 2
0
        public void ShrinkGrid()
        {
            UIDocument uidoc = this.ActiveUIDocument;
            Document   doc   = uidoc.Document;
            Selection  sel   = uidoc.Selection;
            View       view  = doc.ActiveView;
            var        num   = 2;

            ISelectionFilter f       = new JtElementsOfClassSelectionFilter <Grid>();
            Reference        elemRef = uidoc.Selection.PickObject(ObjectType.Element, f, "Pick a Grid");

            Grid          grid       = doc.GetElement(elemRef) as Grid;
            IList <Curve> gridCurves = grid.GetCurvesInView(DatumExtentType.ViewSpecific, view);

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Modify the grid start and end point");
                foreach (var c in gridCurves)
                {
                    XYZ start = c.GetEndPoint(0);
                    XYZ end   = c.GetEndPoint(1);

                    XYZ  newStart = start + num * XYZ.BasisX;
                    XYZ  newEnd   = end - num * XYZ.BasisX;
                    Line newLine  = Line.CreateBound(newStart, newEnd);

//					XYZ crStart = cr.GetEndPoint(0);
//					XYZ crEnd = cr.GetEndPoint(1);
//					Line crLine = Line.CreateBound(crStart, crEnd);

                    grid.SetCurveInView(DatumExtentType.ViewSpecific, view, newLine);
                }
                tx.Commit();
            }
            TaskDialog.Show("Result", "The Grid is extended");
        }