ProjectLocation Class


An object that represents a named location in a project.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public class ProjectLocation : Instance
Visual Basic
Public Class ProjectLocation _
	Inherits Instance
Visual C++
public ref class ProjectLocation : public Instance

Remarks

Revit Architecture projects can have named locations. A named location is the position of a model instance in a Revit Architecture project. By default, each Revit Architecture 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.

Examples

Copy C#
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.get_ProjectPosition(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.SiteLocation;
    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);
}
Copy VB.NET
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.ProjectPosition(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.SiteLocation
    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

See Also