Пример #1
0
        /// <summary>
        /// 为选中房间创建专门的floorPlan和ceilingPlan
        /// Ctrate a New FloorPlan and CeilingPlan for the selected selRoom
        /// </summary>
        /// <param name="viewOffseet"></param>
        /// <param name="view3d"></param>
        public void CreateNewViewPlan(double viewOffseet, View3D view3d)
        {
            //过滤所有的ViewFamilyType
            var classFilter = new ElementClassFilter(typeof(ViewFamilyType));
            FilteredElementCollector collector = new FilteredElementCollector(DocSet.doc);

            collector = collector.WherePasses(classFilter);
            ViewPlan view = null;

            using (Transaction tran = new Transaction(DocSet.doc))
            {
                foreach (ViewFamilyType viewFamilyType in collector)
                {
                    //当类型为FloorPlan或者CeilingPlan时创建同类型视图
                    if (viewFamilyType.ViewFamily == ViewFamily.FloorPlan ||
                        viewFamilyType.ViewFamily == ViewFamily.CeilingPlan)
                    {
                        tran.Start("Creat view of type " + viewFamilyType.ViewFamily);
                        //创建视图时需要 视图类型ID 相关标高ID
                        view = ViewPlan.Create(DocSet.doc, viewFamilyType.Id, DocSet.selRoom.LevelId);

                        //TaskDialog.Show("CreatLevelView", "A new level's view has been Created");

                        view.Name = DocSet.selRoom.Name;//生成平面的名称

                        view.get_Parameter(BuiltInParameter.VIEWER_CROP_REGION).Set(1);
                        view.AreAnalyticalModelCategoriesHidden = false;
                        view.PartsVisibility = PartsVisibility.ShowPartsAndOriginal;
                        view.Scale           = 50;
                        view.CropBoxActive   = true;
                        view.CropBoxVisible  = true;

                        string viewName = "PLAN ";
                        view.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(DocSet.selRoom.Name);

                        if (viewFamilyType.ViewFamily == ViewFamily.CeilingPlan)
                        {
                            PlanViewRange range = view.GetViewRange();
                            range.SetLevelId(PlanViewPlane.TopClipPlane, DocSet.selRoom.UpperLimit.Id);
                            range.SetLevelId(PlanViewPlane.ViewDepthPlane, DocSet.selRoom.UpperLimit.Id);
                            range.SetLevelId(PlanViewPlane.CutPlane, DocSet.selRoom.LevelId);
                            range.SetLevelId(PlanViewPlane.BottomClipPlane, DocSet.selRoom.LevelId);
                            range.SetOffset(PlanViewPlane.CutPlane, 7.874);
                            range.SetOffset(PlanViewPlane.BottomClipPlane, 7.874);
                            view.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(DocSet.selRoom.Name);
                            view.SetViewRange(range);

                            viewName = "RCP ";
                            view.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(DocSet.selRoom.Name + " - RCP");
                        }
                        viewName     += _SoANumber + "_" + DocSet.selRoom.Level.Name;
                        view.ViewName = viewName;
                        tran.Commit();
                        ChangeViewFitRoom(view, tran, viewOffseet);
                    }
                }
            }
        }
Пример #2
0
        private static ViewBox getPlanViewBox(ViewPlan vp)
        {
            System.Diagnostics.Debug.WriteLine("ViewPlan: " + vp.Id + " Outline: " + vp.Outline.Min.U + "," + vp.Outline.Min.V + " to " + vp.Outline.Max.U + "," + vp.Outline.Max.V);
            System.Diagnostics.Debug.WriteLine("ViewPlan Scale: " + vp.Scale);


            XYZ tmp1 = vp.Origin.Add(new XYZ(vp.Outline.Min.U * (double)vp.Scale, vp.Outline.Min.V * (double)vp.Scale, 0));
            XYZ tmp2 = vp.Origin.Add(new XYZ(vp.Outline.Max.U * (double)vp.Scale, vp.Outline.Max.V * (double)vp.Scale, 0));

            // double check the cropbox, if it is smaller...
            if (vp.CropBoxActive)
            {
                tmp1 = vp.CropBox.Min;
                tmp2 = vp.CropBox.Max;
            }

            // in a plan view, we will work with the cropbox (if it is set?)
            ViewBox box = new ViewBox()
            {
                P1 = tmp1, P2 = tmp2
            };

            // now reset by the level and the viewdepth
            if (vp.GenLevel != null)
            {
                PlanViewRange pvr   = vp.GetViewRange();
                ElementId     topId = pvr.GetLevelId(PlanViewPlane.TopClipPlane);

                ElementId bottomId = pvr.GetLevelId(PlanViewPlane.ViewDepthPlane);
                if (bottomId.IntegerValue == -4)
                {
                    bottomId = pvr.GetLevelId(PlanViewPlane.BottomClipPlane);
                }
                if (bottomId.IntegerValue == -4)
                {
                    bottomId = pvr.GetLevelId(PlanViewPlane.UnderlayBottom);
                }

                if (topId != ElementId.InvalidElementId)
                {
                    Level top = vp.Document.GetElement(topId) as Level;
                    box.P2 = new XYZ(box.P2.X, box.P2.Y, top.Elevation + pvr.GetOffset(PlanViewPlane.TopClipPlane));
                }
                if (bottomId != ElementId.InvalidElementId)
                {
                    Level bottom = vp.Document.GetElement(bottomId) as Level;
                    box.P1 = new XYZ(box.P1.X, box.P1.Y, bottom.Elevation + pvr.GetOffset(PlanViewPlane.ViewDepthPlane));
                }
            }

            // set the transform
            box.TransformationMatrix = Transform.Identity;
            box.DirectionUp          = vp.UpDirection;
            box.EyePosition          = vp.Origin.Add(vp.ViewDirection.Multiply(10));
            box.DirectionView        = vp.ViewDirection.Negate();
            return(box);
        }
Пример #3
0
        public bool CopyGridExtent(Document doc, View sourceView, Reference selectedGrid)
        {
            DatumPlane selectedDatum = doc.GetElement(selectedGrid) as DatumPlane;
            Curve      baseCurve     = selectedDatum.GetCurvesInView(DatumExtentType.ViewSpecific, sourceView).ElementAt(0);
            XYZ        basePoint0    = baseCurve.GetEndPoint(0);
            XYZ        basePoint1    = baseCurve.GetEndPoint(1);
            Line       baseLine      = baseCurve as Line;

            Curve newCurve   = selectedDatum.GetCurvesInView(DatumExtentType.ViewSpecific, doc.ActiveView).ElementAt(0);
            XYZ   newCurvePt = newCurve.GetEndPoint(0);
            Line  newLine    = newCurve as Line;

            //sb.AppendLine("Source view end0 " + baseLine.GetEndPoint(0).X.ToString() + " - " + baseLine.GetEndPoint(0).Y.ToString() + " - " + baseLine.GetEndPoint(0).Z.ToString());
            //sb.AppendLine("Active view end0 " + newLine.GetEndPoint(0).X.ToString() + " - " + newLine.GetEndPoint(0).Y.ToString() + " - " + newLine.GetEndPoint(0).Z.ToString());

            //sb.AppendLine("Source view end1 " + baseLine.GetEndPoint(1).X.ToString() + " - " + baseLine.GetEndPoint(1).Y.ToString() + " - " + baseLine.GetEndPoint(1).Z.ToString());
            //sb.AppendLine("Active view end1 " + newLine.GetEndPoint(1).X.ToString() + " - " + newLine.GetEndPoint(1).Y.ToString() + " - " + newLine.GetEndPoint(1).Z.ToString());

            ISet <ElementId> par = new List <ElementId>() as ISet <ElementId>;

            View destination = doc.ActiveView;

            ViewPlan vp = destination as ViewPlan;

            PlanViewRange pvr = vp.GetViewRange();

            Level l = vp.GenLevel;

            double zLevel = pvr.GetOffset(PlanViewPlane.CutPlane) + l.Elevation; //Z point for Datum curve

            //Curve projectedCurve = Line.CreateBound(new XYZ(basePoint0.X, basePoint0.Y, newCurvePt.Z), new XYZ(basePoint1.X, basePoint1.Y, newCurvePt.Z));

            Curve projectedCurve = Line.CreateBound(new XYZ(basePoint0.X, basePoint0.Y, zLevel), new XYZ(basePoint1.X, basePoint1.Y, zLevel));

            //par.Add(destination);

            //TaskDialog.Show("r", par.Count.ToString());


            Grid g = doc.GetElement(selectedGrid) as Grid;

            //g.SetDatumExtentType(DatumEnds.End1, destination, DatumExtentType.ViewSpecific);

            g.SetCurveInView(g.GetDatumExtentTypeInView(DatumEnds.End1, sourceView), destination, projectedCurve);

            //TaskDialog.Show("r", sb.ToString());
            //g.PropagateToViews(source, par);

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Gets the cut plane from a plan view.
        /// </summary>
        /// <param name="plan">The plan view containing the cut plane.</param>
        /// <returns>A plane representing the plan view's cut plane.</returns>
        private static Plane GetViewPlanCutPlane(ViewPlan plan)
        {
            if (null == plan)
            {
                return(null);
            }

            double levelElevation = 0.0;

            if (null != plan.GenLevel)
            {
                levelElevation = plan.GenLevel.Elevation;
            }
            double cutPlaneOffset        = plan.GetViewRange().GetOffset(PlanViewPlane.CutPlane);
            double viewCutPlaneElevation = levelElevation + cutPlaneOffset;

            return(Plane.CreateByNormalAndOrigin(plan.ViewDirection, new XYZ(0.0, 0.0, viewCutPlaneElevation)));
        }
Пример #5
0
        public static Outline Outline(this ViewPlan viewPlan, Transform transform = null)
        {
            if (viewPlan == null)
            {
                return(null);
            }

            PlanViewRange planViewRange = viewPlan.GetViewRange();

            if (planViewRange == null)
            {
                return(null);
            }

            Document document = viewPlan.Document;

            ElementId elementId_Level = null;

            elementId_Level = planViewRange.GetLevelId(PlanViewPlane.TopClipPlane);
            Level  level_TopClipPlane  = document.GetElement(elementId_Level) as Level;
            double offset_TopClipPlane = planViewRange.GetOffset(PlanViewPlane.TopClipPlane);

            elementId_Level = planViewRange.GetLevelId(PlanViewPlane.BottomClipPlane);
            Level  level_BottomClipPlane  = document.GetElement(elementId_Level) as Level;
            double offset_BottomClipPlane = planViewRange.GetOffset(PlanViewPlane.BottomClipPlane);

            BoundingBoxXYZ boundingBoxXYZ = viewPlan.CropBox;

            boundingBoxXYZ.Min = new XYZ(boundingBoxXYZ.Min.X, boundingBoxXYZ.Min.Y, level_BottomClipPlane.Elevation + offset_BottomClipPlane);
            boundingBoxXYZ.Max = new XYZ(boundingBoxXYZ.Max.X, boundingBoxXYZ.Max.Y, level_TopClipPlane.Elevation + offset_TopClipPlane);

            if (transform != null)
            {
                boundingBoxXYZ.Transform = transform.Inverse;
            }

            return(new Outline(boundingBoxXYZ.Min, boundingBoxXYZ.Max));
        }
Пример #6
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication           uiapp        = commandData.Application;
            UIDocument              uidoc        = uiapp.ActiveUIDocument;
            Application             app          = uiapp.Application;
            Document                doc          = uidoc.Document;
            Selection               SelectedObjs = uidoc.Selection;
            ICollection <ElementId> ids          = uidoc.Selection.GetElementIds();
            ViewPlan                viewPlan     = uidoc.ActiveView as ViewPlan;
            PlanViewRange           VR           = null;

            foreach (ElementId eid in ids)
            {
                Element elem = doc.GetElement(eid);
                if (elem.Category.Name == "Views")
                {
                    ViewPlan selectPlan = elem as ViewPlan;
                    VR = selectPlan.GetViewRange();
                    TaskDialog.Show("Copying VR from", selectPlan.Title);
                }
            }
            if (VR == null)
            {
                TaskDialog.Show("error", "error");
            }
            using (Transaction t = new Transaction(doc, "Set View Range"))
            {
                t.Start();
                viewPlan.SetViewRange(VR);
                t.Commit();
            }
            return(Result.Succeeded);
        }
        public static double GetViewPlanCutPlaneElevation(ViewPlan viewPlan)
        {
            var planViewRange = viewPlan.GetViewRange();

            return(planViewRange.GetOffset(PlanViewPlane.CutPlane) + viewPlan.GenLevel.ProjectElevation);
        }
Пример #8
0
        public static void getCurrentView(Document doc, out ViewItem viewItem)
        {
            viewItem = new ViewItem();
            double topPoint;
            double cutPoint;
            double bottPoint;
            double depthPoint;
            double topToCut;
            double cutToBott;
            double bottToDepth;
            double totalRange;

            double originElevOff;
            double originElev = 0;

            originPosition(doc, out originElev);
            originElevOff = 0 - originElev;

            ViewPlan      vP        = doc.ActiveView as ViewPlan;
            PlanViewRange viewRange = vP.GetViewRange();
            Level         hostLevel = doc.GetElement(vP.LevelId) as Level;

            #region view range info
            //Get top clip data
            Level  topClipLevel  = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.TopClipPlane) as ElementId) as Level;
            double topClipElev   = topClipLevel.Elevation + originElevOff;
            double topClipOffset = viewRange.GetOffset(PlanViewPlane.TopClipPlane);
            topPoint = topClipElev + topClipOffset;

            //Get cut plane
            Level  cutLevel     = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.CutPlane) as ElementId) as Level;
            double cutElevation = cutLevel.Elevation + originElevOff;
            double cutOffset    = viewRange.GetOffset(PlanViewPlane.CutPlane);
            cutPoint = cutElevation + cutOffset;

            //Get bottom clip data
            Level  bottClipLevel  = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.BottomClipPlane) as ElementId) as Level;
            double bottClipElev   = bottClipLevel.Elevation + originElevOff;
            double bottClipOffset = viewRange.GetOffset(PlanViewPlane.BottomClipPlane);
            bottPoint = bottClipElev + bottClipOffset;

            //Get depth clip data
            Level  depthClipLevel  = doc.GetElement(viewRange.GetLevelId(PlanViewPlane.ViewDepthPlane) as ElementId) as Level;
            double depthClipElev   = bottClipLevel.Elevation + originElevOff;
            double depthClipOffset = viewRange.GetOffset(PlanViewPlane.ViewDepthPlane);
            depthPoint = depthClipElev + depthClipOffset;

            topToCut    = topPoint - cutPoint;
            cutToBott   = cutPoint - bottPoint;
            bottToDepth = bottPoint - depthPoint;
            totalRange  = topPoint - depthPoint;
            #endregion

            #region add data to ViewItem.
            viewItem.id              = vP.Id;
            viewItem.name            = vP.Name;
            viewItem.hostLevel       = hostLevel;
            viewItem.topClipLevel    = topClipLevel;
            viewItem.topClipOffset   = topClipOffset;
            viewItem.cutLevel        = cutLevel;
            viewItem.cutOffset       = cutOffset;
            viewItem.bottClipLevel   = bottClipLevel;
            viewItem.bottClipOffset  = bottClipOffset;
            viewItem.depthCLipLevel  = depthClipLevel;
            viewItem.depthClipOffset = depthClipOffset;
            viewItem.topToCut        = topToCut;
            viewItem.cutToBott       = cutToBott;
            viewItem.bottToDepth     = bottToDepth;
            viewItem.totalRange      = totalRange;
            #endregion
        }
Пример #9
0
        private static ViewBox getPlanViewBox(ViewPlan vp)
        {
            System.Diagnostics.Debug.WriteLine("ViewPlan: " + vp.Id + " Outline: " + vp.Outline.Min.U + "," + vp.Outline.Min.V + " to " + vp.Outline.Max.U + "," + vp.Outline.Max.V);
            System.Diagnostics.Debug.WriteLine("ViewPlan Scale: " + vp.Scale);

            XYZ tmp1 = vp.Origin.Add(new XYZ(vp.Outline.Min.U * (double)vp.Scale, vp.Outline.Min.V * (double)vp.Scale, 0));
            XYZ tmp2 = vp.Origin.Add(new XYZ(vp.Outline.Max.U * (double)vp.Scale, vp.Outline.Max.V * (double)vp.Scale, 0));

            // double check the cropbox, if it is smaller...
            if (vp.CropBoxActive)
            {
                tmp1 = vp.CropBox.Min;
                tmp2 = vp.CropBox.Max;
            }

            // in a plan view, we will work with the cropbox (if it is set?)
            ViewBox box = new ViewBox() { P1 = tmp1, P2 = tmp2 };

            // now reset by the level and the viewdepth
            if (vp.GenLevel != null)
            {
                PlanViewRange pvr = vp.GetViewRange();
                ElementId topId = pvr.GetLevelId(PlanViewPlane.TopClipPlane);

                ElementId bottomId = pvr.GetLevelId(PlanViewPlane.ViewDepthPlane);
                if (bottomId.IntegerValue == -4)
                    bottomId = pvr.GetLevelId(PlanViewPlane.BottomClipPlane);
                if (bottomId.IntegerValue == -4)
                    bottomId = pvr.GetLevelId(PlanViewPlane.UnderlayBottom);

                if (topId != ElementId.InvalidElementId)
                {
                    Level top = vp.Document.GetElement(topId) as Level;
                    box.P2 = new XYZ(box.P2.X, box.P2.Y, top.Elevation + pvr.GetOffset( PlanViewPlane.TopClipPlane ) );

                }
                if (bottomId != ElementId.InvalidElementId)
                {
                    Level bottom = vp.Document.GetElement(bottomId) as Level;
                    box.P1 = new XYZ(box.P1.X, box.P1.Y, bottom.Elevation + pvr.GetOffset(PlanViewPlane.ViewDepthPlane));
                }
            }

            // set the transform
            box.TransformationMatrix = Transform.Identity;
            box.DirectionUp = vp.UpDirection;
            box.EyePosition = vp.Origin.Add(vp.ViewDirection.Multiply(10));
            box.DirectionView = vp.ViewDirection.Negate();
            return box;
        }
Пример #10
0
        public RoomsCDRTRequest(UIApplication uiApp, String text)
        {
            RVTDocument doc = uiApp.ActiveUIDocument.Document;

            Autodesk.Revit.DB.View activeView = doc.ActiveView;

            //Verify the active view is a floor plan view
            if (activeView.ViewType != ViewType.FloorPlan)
            {
                MessageBox.Show("Please run from a demo floor plan view.");
            }
            else
            {
                //Get the current phase of the active view
                Phase     currentPhase    = doc.GetElement(activeView.get_Parameter(BuiltInParameter.VIEW_PHASE).AsElementId()) as Phase;
                ElementId currentPhaseId  = currentPhase.Id;
                ElementId previousPhaseId = null;
                //Collect the phases of the document
                PhaseArray phaseArray = doc.Phases;

                //Cycle through the phases in the project to get the previous phase
                for (int i = 0; i < phaseArray.Size; i++)
                {
                    //By finding the index of the current phase, which must not be the first phase, the phase in the previous index can be obtained
                    if (phaseArray.get_Item(i).ToString() == currentPhase.ToString() && i != 0)
                    {
                        previousPhaseId = phaseArray.get_Item(i - 1).Id;
                    }
                    i++;
                }

                //Collect the rooms in the current view where their phase is equal to the active view's phase
                List <Room>   currentVisibleRooms       = new FilteredElementCollector(doc, activeView.Id).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements().Cast <Room>().Where(r => r.get_Parameter(BuiltInParameter.ROOM_PHASE).AsElementId() == currentPhaseId).ToList();
                List <string> currentVisibleRoomNumbers = new List <string>();

                //Get the list of currently visible rooms' numbers
                foreach (Room room in currentVisibleRooms)
                {
                    currentVisibleRoomNumbers.Add(room.Number);
                }

                //Only continue if the previous phase was found
                if (previousPhaseId != null)
                {
                    List <Room> previousRoomsToTag = new List <Room>();
                    Outline     outline            = null;
                    try
                    {
                        //This portion will require a new outline from the view's bounding box
                        BoundingBoxXYZ viewBBox = activeView.get_BoundingBox(activeView);
                        //Get the active view as a plan view so the view range can be obtained for the height of the outline
                        ViewPlan      viewPlan      = activeView as ViewPlan;
                        PlanViewRange planViewRange = viewPlan.GetViewRange();
                        double        minX          = viewBBox.Min.X;
                        double        minY          = viewBBox.Min.Y;
                        //The bottom Z point of the outline will be the elevation of the view's level plus the bottom offset
                        double minZ = activeView.GenLevel.Elevation + planViewRange.GetOffset(PlanViewPlane.BottomClipPlane);
                        double maxX = viewBBox.Max.X;
                        double maxY = viewBBox.Max.Y;
                        //The top Z point of the outline will be the elevation of the view's level plust the top offset
                        double maxZ = activeView.GenLevel.Elevation + planViewRange.GetOffset(PlanViewPlane.TopClipPlane);
                        //Generate the minimum and maximum points
                        XYZ minPoint = new XYZ(minX, minY, minZ);
                        XYZ maxPoint = new XYZ(maxX, maxY, maxZ);
                        //Make a new outline from the points
                        outline = new Outline(minPoint, maxPoint);

                        //Establish a new bounding box filter using the outline
                        BoundingBoxIntersectsFilter bboxFilter = new BoundingBoxIntersectsFilter(outline);
                        //The previous rooms will be those that pass the bounding box intersects filter (their bounding boxes intersect the view bounding box) and they belong to the previous phase
                        var previousNonVisibleRooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().WherePasses(bboxFilter).ToElements().Where(r => r.get_Parameter(BuiltInParameter.ROOM_PHASE).AsElementId() == previousPhaseId);
                        foreach (Element elem in previousNonVisibleRooms)
                        {
                            //Get the rooms and their numbers
                            Room   room       = elem as Room;
                            string roomNumber = room.Number;
                            //Verify the room number is not in the current view's list of visible room numbers
                            if (!currentVisibleRoomNumbers.Contains(roomNumber))
                            {
                                previousRoomsToTag.Add(room);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        //If something went wrong in getting the demoed rooms, report an error
                        MessageBox.Show(e.ToString(), "Getting Demo Rooms Error");
                    }

                    //Start a transaction to make the new tags
                    Transaction t = new Transaction(doc, "Create Demo Room Tags");
                    t.Start();
                    FamilySymbol symbol = null;
                    //Create a new instance of the load options
                    IFamilyLoadOptions loadOptions = new RVTFamilyLoadOptions();

                    try
                    {
                        //Get the versioned symbol family to use as a "tag"
                        string roomTagSymbolPath = RVTOperations.GetVersionedFamilyFilePath(uiApp, Properties.Settings.Default.RevitRoomTagSymbol);
                        try
                        {
                            //Load only the particular type of tag
                            doc.LoadFamilySymbol(roomTagSymbolPath, Properties.Settings.Default.RevitRoomTagSymbolType, loadOptions, out FamilySymbol symb);
                            symbol = symb;
                        }
                        catch
                        {
                            //If it could not be loaded, let the user know it needs added to the family for the script to work
                            MessageBox.Show(String.Format("The family type {0} could not be found in {1}. Please add it for this tool to work.",
                                                          Properties.Settings.Default.RevitRoomTagSymbolType,
                                                          Properties.Settings.Default.RevitRoomTagSymbol));
                        }
                    }
                    catch
                    {
                        //If the family itself could not be loaded, let the user know where the family was expected to be found.
                        MessageBox.Show(String.Format("The {0} family could not be found at {1}. Please place the {0} family in the {1} folder for this tool to work.",
                                                      Path.GetFileNameWithoutExtension(Properties.Settings.Default.RevitRoomTagSymbol),
                                                      Path.GetDirectoryName(Properties.Settings.Default.RevitRoomTagSymbol)));
                    }

                    try
                    {
                        //Verify there are rooms to tag and the family symbol to use is not null
                        if (previousRoomsToTag.Count > 0 && symbol != null)
                        {
                            //Cycle through the demoed rooms
                            foreach (Room demoRoom in previousRoomsToTag)
                            {
                                //Get the location point of the demo room as a point
                                LocationPoint roomLocationPoint = demoRoom.Location as LocationPoint;
                                //Make a new symbol at the locatoin
                                FamilyInstance newSymbol = doc.Create.NewFamilyInstance(roomLocationPoint.Point, symbol, activeView);
                                //Update the parameter values for room Name and Number in the symbol
                                newSymbol.GetParameters("Name").First().Set(demoRoom.get_Parameter(BuiltInParameter.ROOM_NAME).AsString());
                                newSymbol.GetParameters("Number").First().Set(demoRoom.get_Parameter(BuiltInParameter.ROOM_NUMBER).AsString());
                            }
                        }
                        t.Commit();
                    }
                    catch (Exception f)
                    {
                        //Well, crap, the symbol didn't place in the view
                        MessageBox.Show(f.ToString(), "Placement Error");
                        t.RollBack();
                    }
                }
                else
                {
                    //If the previous phase was null, then the current phase of the view is the first phase, so let the user know
                    MessageBox.Show("The currently viewed phase is the earliest phase in the project. Please verify you are viewing a new construction phase, but showing previous and demoed elements.");
                }
            }
        }