Namespace:
Autodesk.Revit.DB
Assembly:
RevitAPI
(in RevitAPI.dll) Version: 18.0.0.0 (18.0.0.420)
Syntax
Remarks
When using shared coordinates, ProjectLocations can be used to specify specific locations for instances of a linked model. A ProjectLocation keeps track of the position of an instance in relationship to the project's SiteLocation.
By default, each Revit project contains at least one named location, called Internal. Existing ProjectLocation objects can be found by using the ProjectLocations property on the Document object. New project locations can be created by duplicating an existing project location using the Duplicate method, and modifying the location's project position.
See also SiteLocationExamples
![](https://d24b2zsrnzhmgb.cloudfront.net/static/img/chm/icons/CopyCode.gif)
public void ShowActiveProjectLocationUsage(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)
{
throw new 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
const double angleRatio = Math.PI / 180; // angle conversion factor
SiteLocation site = projectLocation.GetSiteLocation();
prompt += "\n\t" + "Site location:";
prompt += "\n\t\t" + "Latitude: " + site.Latitude / angleRatio + "��";
prompt += "\n\t\t" + "Longitude: " + site.Longitude / angleRatio + "��";
prompt += "\n\t\t" + "TimeZone: " + site.TimeZone;
// Give the user some information
TaskDialog.Show("Revit",prompt);
}
![](https://d24b2zsrnzhmgb.cloudfront.net/static/img/chm/icons/CopyCode.gif)
Public Sub ShowActiveProjectLocationUsage(document As Autodesk.Revit.DB.Document)
' Get the project location handle
Dim projectLocation As ProjectLocation = document.ActiveProjectLocation
' Show the information of current project location
Dim origin As New XYZ(0, 0, 0)
Dim position As ProjectPosition = projectLocation.GetProjectPosition(origin)
If position Is Nothing Then
Throw New Exception("No project position in origin point.")
End If
' Format the prompt string to show the message.
Dim prompt As [String] = "Current project location information:" & vbLf
prompt += vbLf & vbTab & "Origin point position:"
prompt += (vbLf & vbTab & vbTab & "Angle: ") + position.Angle
prompt += (vbLf & vbTab & vbTab & "East to West offset: ") + position.EastWest
prompt += (vbLf & vbTab & vbTab & "Elevation: ") + position.Elevation
prompt += (vbLf & vbTab & vbTab & "North to South offset: ") + position.NorthSouth
' Angles are in radians when coming from Revit API, so we
' convert to degrees for display
Const angleRatio As Double = Math.PI / 180
' angle conversion factor
Dim site As SiteLocation = projectLocation.GetSiteLocation()
prompt += vbLf & vbTab & "Site location:"
prompt += vbLf & vbTab & vbTab & "Latitude: " & site.Latitude / angleRatio & "��"
prompt += vbLf & vbTab & vbTab & "Longitude: " & site.Longitude / angleRatio & "��"
prompt += (vbLf & vbTab & vbTab & "TimeZone: ") + site.TimeZone
' Give the user some information
TaskDialog.Show("Revit", prompt)
End Sub
Inheritance Hierarchy
Autodesk.Revit.DB Element
Autodesk.Revit.DB Instance
Autodesk.Revit.DB ProjectLocation