Esempio n. 1
0
        private bool updatePositionsInit(Autodesk.Revit.DB.ViewSheet curViewSheet)
        {
            Autodesk.Revit.DB.XYZ       norXYZ          = null;
            Autodesk.Revit.DB.ElementId deltaViewportId = null;

            if (curViewSheet != null)
            {
                ICollection <ElementId> curViewportsIdsCollection = curViewSheet.GetAllViewports();
                foreach (ElementId curViewportId in curViewportsIdsCollection)
                {
                    if (this.selViewportsIdsAndPositions.ContainsKey(curViewportId))
                    {
                        Autodesk.Revit.DB.Viewport curViewport = doc.GetElement(curViewportId) as Autodesk.Revit.DB.Viewport;
                        if (curViewport != null)
                        {
                            norXYZ = curViewport.GetBoxCenter();

                            break;
                        }
                    }
                }
            }

            List <ElementId> viewportIds            = new List <ElementId>(this.selViewportsIdsAndPositions.Keys);
            PageAlignmentToolRequestHandler handler = new PageAlignmentToolRequestHandler(norXYZ, deltaViewportId, viewportIds);
            ExternalEvent exEvent = ExternalEvent.Create(handler);

            exEvent.Raise();

            return(true);
        }
Esempio n. 2
0
        private bool updatePositions(Autodesk.Revit.DB.ViewSheet curViewSheet)
        {
            Autodesk.Revit.DB.XYZ       norXYZ          = null;
            Autodesk.Revit.DB.XYZ       deltaXYZ        = null;
            Autodesk.Revit.DB.ElementId deltaViewportId = null;

            if (curViewSheet != null)
            {
                ICollection <ElementId> curViewportsIdsCollection = curViewSheet.GetAllViewports();
                foreach (ElementId curViewportId in curViewportsIdsCollection)
                {
                    if (this.selViewportsIdsAndPositions.ContainsKey(curViewportId))
                    {
                        Autodesk.Revit.DB.Viewport curViewport = doc.GetElement(curViewportId) as Autodesk.Revit.DB.Viewport;
                        if (curViewport != null)
                        {
                            norXYZ = curViewport.GetBoxCenter();
                            Autodesk.Revit.DB.XYZ preXYZ = this.selViewportsIdsAndPositions[curViewportId];
                            Autodesk.Revit.DB.XYZ curXYZ = curViewport.GetBoxCenter();

                            if ((curXYZ.X != preXYZ.X) || (curXYZ.Y != preXYZ.Y) || (curXYZ.Z != preXYZ.Z))
                            {
                                deltaViewportId = curViewportId;
                                deltaXYZ        = new XYZ((curXYZ.X - preXYZ.X), (curXYZ.Y - preXYZ.Y), (curXYZ.Z - preXYZ.Z));

                                break;
                            }
                        }
                    }
                }
            }

            if ((deltaXYZ != null) && (deltaViewportId != null))
            {
                List <ElementId> viewportIds            = new List <ElementId>(this.selViewportsIdsAndPositions.Keys);
                PageAlignmentToolRequestHandler handler = new PageAlignmentToolRequestHandler(norXYZ, deltaViewportId, viewportIds);
                ExternalEvent exEvent = ExternalEvent.Create(handler);
                exEvent.Raise();

                return(true);
            }

            return(false);
        }