Set a dimension to drive the value of this parameter.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since:
2016 Subscription Update
Syntax
C# |
---|
public void SetDrivingDimension(
ElementId dimensionId
) |
Visual Basic |
---|
Public Sub SetDrivingDimension ( _
dimensionId As ElementId _
) |
Visual C++ |
---|
public:
void SetDrivingDimension(
ElementId^ dimensionId
) |
Remarks
Examples
CopyC#
public bool AssignDrivingDimension(Document document, ElementId gpid, ElementId dimid)
{
GlobalParameter gp = document.GetElement(gpid) as GlobalParameter;
if (gp == null)
return false;
Dimension dim = document.GetElement(dimid) as Dimension;
if (dim == null)
return false;
if (!gp.CanLabelDimension(dimid))
return false;
using (Transaction trans = new Transaction(document,"Assign a driving dimension"))
{
trans.Start();
ISet<ElementId> dimset = gp.GetLabeledDimensions();
foreach (ElementId elemid in dimset)
{
gp.UnlabelDimension(elemid);
}
gp.SetDrivingDimension(dimid);
if (trans.Commit() != TransactionStatus.Committed)
return false;
}
return true;
}
CopyVB.NET
Public Function AssignDrivingDimension(document As Document, gpid As ElementId, dimid As ElementId) As Boolean
Dim gp As GlobalParameter = TryCast(document.GetElement(gpid), GlobalParameter)
If gp Is Nothing Then
Return False
End If
Dim [dim] As Dimension = TryCast(document.GetElement(dimid), Dimension)
If [dim] Is Nothing Then
Return False
End If
If Not gp.CanLabelDimension(dimid) Then
Return False
End If
Using trans As New Transaction(document, "Assign a driving dimension")
trans.Start()
Dim dimset As ISet(Of ElementId) = gp.GetLabeledDimensions()
For Each elemid As ElementId In dimset
gp.UnlabelDimension(elemid)
Next
gp.SetDrivingDimension(dimid)
If trans.Commit() <> TransactionStatus.Committed Then
Return False
End If
End Using
Return True
End Function
Exceptions
Exception | Condition |
---|
Autodesk.Revit.Exceptions..::..ArgumentException |
Given element Id is not of a valid dimension element.
-or-
Dimension with the Id of dimensionId cannot be labeled by this global parameter.
Possible causes include the dimension cannot be labeled at all, or it is a dimension
of other than Linear or Angular type, or the Dimension object does not have the
appropriate labeling parameter, or the dimension has more than one segment and the parameter
is reporting.
|
Autodesk.Revit.Exceptions..::..ArgumentNullException |
A non-optional argument was NULL
|
Autodesk.Revit.Exceptions..::..InvalidOperationException |
This is a formula-driven parameter. As such it does not allow the current operation.
-or-
This non-reporting global parameter has already labeled other dimension segments (more then 1).
It cannot, therefore, be made reporting and dimension-driven before un-labeling all
the dependent dimensions first.
|
See Also