publicvoidShowActiveProjectLocationUsage(Autodesk.Revit.DB.Document document) { // Get the project location handle ProjectLocation projectLocation = document.ActiveProjectLocation;
// Show the information of current project location XYZ origin = new XYZ(0, 0, 0); ProjectPosition position = projectLocation.GetProjectPosition(origin); if (null == position) { thrownew Exception("No project position in origin point."); }
// Format the prompt string to show the message. String prompt = "Current project location information:\n"; prompt += "\n\t" + "Origin point position:"; prompt += "\n\t\t" + "Angle: " + position.Angle; prompt += "\n\t\t" + "East to West offset: " + position.EastWest; prompt += "\n\t\t" + "Elevation: " + position.Elevation; prompt += "\n\t\t" + "North to South offset: " + position.NorthSouth;
// Angles are in radians when coming from Revit API, so we // convert to degrees for display constdouble angleRatio = Math.PI / 180; // angle conversion factor
publicvoidDeleteLocation(Autodesk.Revit.DB.Document document) { ProjectLocation currentLocation = document.ActiveProjectLocation; //There must be at least one project location in the project. ProjectLocationSet locations = document.ProjectLocations; if (1 == locations.Size) { return; }
string name = "location"; if (name != currentLocation.Name) { foreach (ProjectLocation projectLocation in locations) { if (projectLocation.Name == name) { ICollection<Autodesk.Revit.DB.ElementId> elemSet = document.Delete(projectLocation.Id); if (elemSet.Count > 0) { TaskDialog.Show("Revit","Project Location Deleted!"); } } } } }