Generate a new linear dimension object using the default dimension type.
Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Parameters
- view
- Type: Autodesk.Revit.DB View
The view in which the dimension is to be visible.
- line
- Type: Autodesk.Revit.DB Line
The extension line of the dimension.
- references
- Type: Autodesk.Revit.DB ReferenceArray
An array of geometric references to which the dimension is to be bound. You must supply at least two references, and all references supplied must be parallel to each other and perpendicular to the extension line.
Return Value
If creation was successful the new linear dimension is returned, otherwise an exception with failure information will be thrown.Remarks
The currently user set default style is used for the created dimension.
Examples

public Dimension CreateLinearDimension(Document document)
{
// first create two lines
XYZ pt1 = new XYZ(5, 5, 0);
XYZ pt2 = new XYZ(5, 10, 0);
Line line = Line.CreateBound(pt1, pt2);
Plane plane = document.Application.Create.NewPlane(pt1.CrossProduct(pt2), pt2);
SketchPlane skplane = SketchPlane.Create (document, plane);
ModelCurve modelcurve1 = document.FamilyCreate.NewModelCurve(line, skplane);
pt1 = new XYZ(10, 5, 0);
pt2 = new XYZ(10, 10, 0);
line = Line.CreateBound(pt1, pt2);
plane = document.Application.Create.NewPlane(pt1.CrossProduct(pt2), pt2);
skplane = SketchPlane.Create (document, plane);
ModelCurve modelcurve2 = document.FamilyCreate.NewModelCurve(line, skplane);
// now create a linear dimension between them
ReferenceArray ra = new ReferenceArray();
ra.Append(modelcurve1.GeometryCurve.Reference);
ra.Append(modelcurve2.GeometryCurve.Reference);
pt1 = new XYZ(5, 10, 0);
pt2 = new XYZ(10, 10, 0);
line = Line.CreateBound(pt1, pt2);
Dimension dim = document.FamilyCreate.NewLinearDimension(document.ActiveView, line, ra);
// create a label for the dimension called "width"
FamilyParameter param = document.FamilyManager.AddParameter("width",
BuiltInParameterGroup.PG_CONSTRAINTS,
ParameterType.Length, false);
dim.FamilyLabel = param;
return dim;
}

Public Function CreateLinearDimension(document As Document) As Dimension
' first create two lines
Dim pt1 As New XYZ(5, 5, 0)
Dim pt2 As New XYZ(5, 10, 0)
Dim line__1 As Line = Line.CreateBound(pt1, pt2)
Dim plane As Plane = document.Application.Create.NewPlane(pt1.CrossProduct(pt2), pt2)
Dim skplane As SketchPlane = SketchPlane.Create(document, plane)
Dim modelcurve1 As ModelCurve = document.FamilyCreate.NewModelCurve(line__1, skplane)
pt1 = New XYZ(10, 5, 0)
pt2 = New XYZ(10, 10, 0)
line__1 = Line.CreateBound(pt1, pt2)
plane = document.Application.Create.NewPlane(pt1.CrossProduct(pt2), pt2)
skplane = SketchPlane.Create(document, plane)
Dim modelcurve2 As ModelCurve = document.FamilyCreate.NewModelCurve(line__1, skplane)
' now create a linear dimension between them
Dim ra As New ReferenceArray()
ra.Append(modelcurve1.GeometryCurve.Reference)
ra.Append(modelcurve2.GeometryCurve.Reference)
pt1 = New XYZ(5, 10, 0)
pt2 = New XYZ(10, 10, 0)
line__1 = Line.CreateBound(pt1, pt2)
Dim [dim] As Dimension = document.FamilyCreate.NewLinearDimension(document.ActiveView, line__1, ra)
' create a label for the dimension called "width"
Dim param As FamilyParameter = document.FamilyManager.AddParameter("width", BuiltInParameterGroup.PG_CONSTRAINTS, ParameterType.Length, False)
[dim].FamilyLabel = param
Return [dim]
End Function
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions ArgumentNullException | Thrown when any input argument is a null reference ( Nothing in Visual Basic) . |
Autodesk.Revit.Exceptions ArgumentException | Thrown when the argument "references" is invalid. |
Autodesk.Revit.Exceptions InvalidOperationException | Thrown when the creation failed. |