BuildingCoder.CmdCoordsOfViewOnSheet.Execute C# (CSharp) Method

Execute() public method

public Execute ( ExternalCommandData commandData, String &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message String
elements ElementSet
return System.Result
        public Result Execute(
            ExternalCommandData commandData,
            ref String message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              Document doc = app.ActiveUIDocument.Document;

              ViewSheet currentSheet
            = doc.ActiveView as ViewSheet;

              //foreach( View v in currentSheet.Views ) // 2014 warning	'Autodesk.Revit.DB.ViewSheet.Views' is obsolete.  Use GetAllPlacedViews() instead.

              foreach( ElementId id in currentSheet.GetAllPlacedViews() ) // 2015
              {
            View v = doc.GetElement( id ) as View;

            // the values returned here do not seem to
            // accurately reflect the positions of the
            // views on the sheet:

            BoundingBoxUV loc = v.Outline;

            Debug.Print(
              "Coordinates of {0} view '{1}': {2}",
              v.ViewType, v.Name,
              Util.PointString( loc.Min ) );
              }

              return Result.Failed;
        }
CmdCoordsOfViewOnSheet