Exemplo n.º 1
0
        /// <summary>
        /// Function for user to pick up line
        /// </summary>
        /// <param name="uidoc"></param>
        /// <returns></returns>
        public static ElementId PickLine(UIDocument uidoc)
        {
            Document doc = uidoc.Document;

            // Selection filter
            ISelectionFilter selFilter = new LineSelectionFilter();

            try
            {
                // Prompt user to select curve that intersects with rooms
                ElementId curveId = uidoc.Selection.PickObject(ObjectType.Element, selFilter).ElementId;

                // Retrieve model curve
                //CurveElement eCurve = doc.GetElement(curveId) as CurveElement;
                //Curve curve = eCurve.GeometryCurve as Curve;

                // TaskDialog.Show("Curve Picked", curve.Name);
                return(curveId);
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException e)
            {
                TaskDialog.Show("Operation Canceled", e.Message);
                return(null);
            }
        }
Exemplo n.º 2
0
        public void DoorRenumbering()
        {
            UIDocument uidoc   = ActiveUIDocument;
            Document   doc     = ActiveUIDocument.Document;
            View       current = doc.ActiveView;

            ISelectionFilter filter = new LineSelectionFilter();

            Reference reference = uidoc.Selection.PickObject(ObjectType.Element, filter, "Select direction curve");

            Curve curve = (doc.GetElement(reference.ElementId) as ModelCurve).GeometryCurve;

            FilteredElementCollector collector = new FilteredElementCollector(doc, current.Id);

            List <Element> elements = collector.OfCategory(BuiltInCategory.OST_Doors).ToList();

            List <LocationPoint> points = new List <LocationPoint>();

            string s         = "";
            int    numPoints = 0;
            Dictionary <Element, double> sort = new Dictionary <Element, double>();

            foreach (Element element in elements)
            {
                FamilyInstance door = element as FamilyInstance;

                XYZ point = door.GetTransform().Origin;

                if (point == null)
                {
                    continue;
                }

                IntersectionResult closestPoint = curve.Project(point);

                sort.Add(element, curve.ComputeNormalizedParameter(closestPoint.Parameter));
            }

            List <Element> sorted = sort.OrderBy(x => x.Value).Select(x => x.Key).ToList();

            using (Transaction t = new Transaction(doc, "Rename Mark Values"))
            {
                t.Start();
                foreach (Element el in sorted)
                {
                    el.LookupParameter("Mark").Set(numPoints.ToString());
                    numPoints++;
                }
                t.Commit();
            }
        }