示例#1
0
        /// <summary>
        /// Method to select multiple areas...
        /// Selected areas show up one by one...
        /// No highlighting of selected objects
        /// </summary>
        /// <param name="collectionVM"></param>
        /// <param name="uidoc"></param>
        /// <param name="counter"></param>
        internal static void GetAreasByIndividualSelection(AreaCollectionVM collectionVM, UIDocument uidoc, ref int counter)
        {
            while (!collectionVM.StopSelection)
            {
                Reference pickedRef;
                try
                {
                    // try catch to capture escape options
                    pickedRef = uidoc.Selection.PickObject(ObjectType.Element, new AreaSelectionFilter());
                }
                catch { break; }

                if (collectionVM.StopSelection)
                {
                    break;
                }

                var     refeId      = pickedRef.ElementId;
                Element areaElement = uidoc.Document.GetElement(refeId);
                Area    area        = areaElement as Area;


                collectionVM.AddArea(area, counter);
                counter++;
            }
        }
示例#2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uidoc.Document;


            // set up UI
            // check to see if an open window already exists

            if (null == m_AreaCollectionVM)
            {
                m_AreaCollectionVM = new AreaCollectionVM();
                m_PickOptionsCtrl  = new PickOptionsCtrl(m_AreaCollectionVM);
            }
            Window win = new Window();

            win.Width         = 300;
            win.Content       = m_PickOptionsCtrl;
            win.SizeToContent = SizeToContent.WidthAndHeight;
            win.Topmost       = true;
            win.Show();

            int counter = 0;
            // make area interior fill visible
            Category interiorFillVisibility = Category.GetCategory(doc, BuiltInCategory.OST_AreaInteriorFillVisibility);
            Category areaRef = Category.GetCategory(doc, BuiltInCategory.OST_AreaReferenceVisibility);

            using (Transaction t = new Transaction(doc))
            {
                t.Start("Showing Area Interior Fill");
                doc.ActiveView.SetCategoryHidden(interiorFillVisibility.Id, false);
                doc.ActiveView.SetCategoryHidden(areaRef.Id, false);
                t.Commit();
            }

            // works for individual selection  - no highlighting of selected area
            //SelectionUtils.GetAreasByIndividualSelection(m_AreaCollectionVM, uidoc, ref counter);

            // works for mulitple selection - highlights, but does not update on interface
            while (!m_AreaCollectionVM.StopSelection)
            {
                SelectionUtils.GetAreasByMultipleSelection(m_AreaCollectionVM, uidoc, ref counter);
            }


            if (m_AreaCollectionVM.UpdateParameters)
            {
                // run process to update parameters according to the view model
                // TODO.............................
            }

            return(Result.Succeeded);
        }
示例#3
0
        /// <summary>
        /// method to select multiple areas
        /// selected areas shows up to gether
        /// selected objects are highlighted
        /// </summary>
        /// <param name="collectionVM"></param>
        /// <param name="uidoc"></param>
        /// <param name="counter"></param>
        internal static void GetAreasByMultipleSelection(AreaCollectionVM collectionVM, UIDocument uidoc, ref int counter)
        {
            IList <Reference>       areasReferences = null;
            ICollection <ElementId> selectedIds     = null;

            try
            {
                areasReferences = uidoc.Selection.PickObjects(ObjectType.Element, new AreaSelectionFilter());
            }
            catch
            {
                if (collectionVM.StopSelection)
                {
                    return;
                }
                /*operation cancelled*/
                TaskDialog.Show("Error", "Please select 'Finish' in the 'Options Bar' of the interface to complete the selection");
                // exit command and close window
                return;
            }

            if (null == areasReferences && null == selectedIds)
            {
                return;
            }
            // if no references were found, but selected items were retrieved
            if (null == selectedIds && null != areasReferences)
            {
                selectedIds = areasReferences.Select(x => x.ElementId).ToList();
            }

            // use selected ids
            var areasElements = selectedIds.Select(x => uidoc.Document.GetElement(x));

            foreach (Element areaElement in areasElements)
            {
                Area area = areaElement as Area;
                collectionVM.AddArea(area, counter);
                counter++;
            }
        }
示例#4
0
 public PickOptionsCtrl(AreaCollectionVM areaCollectionVM)
 {
     InitializeComponent();
     this.DataContext = m_areaCollectionVm = areaCollectionVM;
 }