示例#1
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiApp      = commandData.Application;
            Document      currentDoc = uiApp.ActiveUIDocument.Document;
            View          av         = currentDoc.ActiveView;

            ViewFamilyType vft = GenerateViews.ViewTypeSetup(currentDoc);

            if (av.ViewType == ViewType.FloorPlan)
            {
                RoomFilter            filt    = new RoomFilter();
                ICollection <Element> roomset = new FilteredElementCollector(currentDoc, av.Id).WherePasses(filt).ToElements();
                foreach (Element e in roomset)
                {
                    Room r = e as Room;
                    GenerateViews.GenViews(vft, av, r);
                }
            }
            else
            {
                TaskDialog.Show("Error", "Active a plan view!");
            }
            return(Result.Succeeded);
        }
示例#2
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiApp      = commandData.Application;
            Document      currentDoc = uiApp.ActiveUIDocument.Document;
            UIDocument    uiDoc      = uiApp.ActiveUIDocument;
            View          av         = currentDoc.ActiveView;

            ViewFamilyType vft = GenerateViews.ViewTypeSetup(currentDoc);

            if (av.ViewType == ViewType.FloorPlan)
            {
                Selection sel = uiDoc.Selection;
                ICollection <ElementId> set = sel.GetElementIds();

                if (set.Count == 1)
                {
                    foreach (ElementId id in set)
                    {
                        Element e = currentDoc.GetElement(id);
                        Room    r = e as Room;
                        if (null != r)
                        {
                            BoundaryData b = new BoundaryData(r);
                            GenerateViews.GenViews(vft, av, r);
                        }
                        else
                        {
                            TaskDialog.Show("Error", "Please select a room.");
                        }
                    }
                }
                else
                {
                    TaskDialog.Show("Error", "Please select a room.");
                }
            }
            else
            {
                TaskDialog.Show("Error", "Active a plan view!");
            }
            return(Result.Succeeded);
        }