Duplicate Method


Generate a copy of this project location with the specified name.

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

Syntax

C#
public ProjectLocation Duplicate(
	string name
)
Visual Basic
Public Function Duplicate ( _
	name As String _
) As ProjectLocation
Visual C++
public:
ProjectLocation^ Duplicate(
	String^ name
)

Parameters

name
Type: System String

Return Value

A new ProjectLocation which is a duplicate of this location, with the input name.

Remarks

The name must not be the same as the name of any existing locations. This function will modify the document, as the new ProjectLocation will be added to it.

Examples

Copy C#
public ProjectLocation DuplicateLocation(Autodesk.Revit.DB.Document document, string newName)
{
    ProjectLocation currentLocation = document.ActiveProjectLocation;
    ProjectLocationSet locations = document.ProjectLocations;
    foreach (ProjectLocation projectLocation in locations)
    {
        if (projectLocation.Name == newName)
        {
            throw new Exception("The name is same as a project location's name, please change one.");
        }
    }
    return currentLocation.Duplicate(newName);
}
Copy VB.NET
Public Function DuplicateLocation(document As Autodesk.Revit.DB.Document, newName As String) As ProjectLocation
    Dim currentLocation As ProjectLocation = document.ActiveProjectLocation
    Dim locations As ProjectLocationSet = document.ProjectLocations
    For Each projectLocation As ProjectLocation In locations
        If projectLocation.Name = newName Then
            Throw New Exception("The name is same as a project location's name, please change one.")
        End If
    Next
    Return currentLocation.Duplicate(newName)
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL

See Also