Posts a failure to be displayed to the user at the end of transaction.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 23.0.0.0 (23.1.0.0)
Since:
2011
Syntax
Return Value
A unique key that identifies posted failure message in a document. If exactly the same error is posted more than once,
and not removed between the postings, returned key will be the same every time.
Remarks
Examples
CopyC#
public void Execute(UpdaterData data)
{
Document doc = data.GetDocument();
Autodesk.Revit.ApplicationServices.Application app = doc.Application;
foreach (ElementId id in data.GetModifiedElementIds())
{
AnalyticalMember fi = doc.GetElement(id) as AnalyticalMember;
if (fi.StructuralRole == AnalyticalStructuralRole.StructuralRoleBeam)
{
if (fi.IsSingleCurve() == true)
{
Curve beamCurve = fi.GetCurve();
if (beamCurve.Length < 12.0)
{
FailureMessage failMessage =
new FailureMessage(BuiltInFailures.CurveFailures.TooShort);
failMessage.SetFailingElement(id);
doc.PostFailure(failMessage);
}
}
}
}
}
CopyVB.NET
Public Sub Execute(data As UpdaterData) Implements IUpdater.Execute
Dim doc As Document = data.GetDocument()
Dim app As Autodesk.Revit.ApplicationServices.Application = doc.Application
For Each id As ElementId In data.GetModifiedElementIds()
Dim fi As FamilyInstance = TryCast(doc.GetElement(id), FamilyInstance)
If fi.StructuralType = StructuralType.Beam Then
Dim analyticalModel As Autodesk.Revit.DB.Structure.AnalyticalElement = Nothing
Dim relManager As Autodesk.Revit.DB.Structure.AnalyticalToPhysicalAssociationManager = Autodesk.Revit.DB.Structure.AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(doc)
If (relManager Is Nothing) Then
Exit Sub
End If
Dim counterpartId As ElementId = relManager.GetAssociatedElementId(fi.Id)
If (counterpartId Is Nothing) Then
Exit Sub
End If
analyticalModel = doc.GetElement(counterpartId)
If analyticalModel.IsSingleCurve() = True Then
Dim beamCurve As Curve = analyticalModel.GetCurve()
If beamCurve.Length < 12.0 Then
Dim failMessage As New FailureMessage(BuiltInFailures.CurveFailures.TooShort)
failMessage.SetFailingElement(id)
doc.PostFailure(failMessage)
End If
End If
End If
Next
End Sub
Exceptions
See Also