NewDimension Method (View, Line, ReferenceArray)


Creates a new linear dimension object using the default dimension style.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 18.0.0.0 (18.2.0.0)

Syntax

C#
public Dimension NewDimension(
	View view,
	Line line,
	ReferenceArray references
)
Visual Basic
Public Function NewDimension ( _
	view As View, _
	line As Line, _
	references As ReferenceArray _
) As Dimension
Visual C++
public:
Dimension^ NewDimension(
	View^ view, 
	Line^ line, 
	ReferenceArray^ references
)

Parameters

view
Type: Autodesk.Revit.DB View
The view in which the dimension is to be visible.
line
Type: Autodesk.Revit.DB Line
The line drawn for the dimension.
references
Type: Autodesk.Revit.DB ReferenceArray
An array of geometric references to which the dimension is to be bound.

Return Value

If successful a new dimension object, otherwise a null reference ( Nothing in Visual Basic) .

Remarks

The currently user set default style is used for the created dimension.

Examples

Copy C#
Dimension CreateNewDimensionAlongLine(Autodesk.Revit.DB.Document document, Line line)
{
    // Use the Start and End points of our line as the references  
    // Line must come from something in Revit, such as a beam
    ReferenceArray references = new ReferenceArray();
    references.Append(line.GetEndPointReference(0));
    references.Append(line.GetEndPointReference(1));

    // create the new dimension
    Dimension dimension = document.Create.NewDimension(document.ActiveView,
                                                        line, references);
    return dimension;
}
Copy VB.NET
Private Function CreateNewDimensionAlongLine(document As Autodesk.Revit.DB.Document, line As Line) As Dimension
    ' Use the Start and End points of our line as the references  
    ' Line must come from something in Revit, such as a beam
    Dim references As New ReferenceArray()
    references.Append(line.GetEndPointReference(0))
    references.Append(line.GetEndPointReference(1))

    ' create the new dimension
    Dim dimension As Dimension = document.Create.NewDimension(document.ActiveView, line, references)
    Return dimension
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException Thrown when references are not geometric references.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →