该类包含Revit中与斜柱相关的故障类型。
故障类型 | 描述 |
---|---|
ColumnMustBeVertical | 列必须垂直。 |
SlantedColumnNotValid | 斜柱无效。 |
SlantedColumnsCollide | 斜柱相互碰撞。 |
SlantedColumnEndPointsBad | 斜柱端点不正确。 |
CantMakeSlantedColumn | 不能创建斜柱。 |
SlantedColumnOutOfRange | 斜柱越界。 |
SlantedColumnsOverlap | 斜柱重叠。 |
使用FailureDefinitionId
类来检查是否发生这些故障:
private void CheckFailures(Document doc)
{
FailureMessage message = null;
IList<FailureMessageAccessor> failList = new List<FailureMessageAccessor>();
FailureHandlingOptions failOpts = new FailureHandlingOptions();
// Collect all the elements of category OST_Column.
FilteredElementCollector collector = new FilteredElementCollector(doc);
ElementCategoryFilter catFilter = new ElementCategoryFilter(BuiltInCategory.OST_Columns);
collector.WherePasses(catFilter);
foreach (Element elem in collector)
{
// Check element for slanted column failures.
failOpts.SetClearAfterRollback(false);
failOpts.SetDelayedMiniWarnings(false);
failOpts.SetFailuresPreprocessor(new SlantedColumnChecker());
try
{
doc.PostCheckElements(failOpts, failList, elem);
}
catch (Autodesk.Revit.Exceptions.ArgumentNullException)
{
// Log message indicating that the element was null.
}
// If there were failure messages, display them.
if (failList.Count > 0)
{
foreach (FailureMessageAccessor failure in failList)
{
message = failure.GetFailureMessage();
// Log the failure message.
}
}
}
}
使用FailureMessageAccessor.GetFailureDefinitionId()
方法来获取FailureDefinitionId
:
FailureDefinitionId failId = failure.GetFailureDefinitionId()
if (BuiltInFailures.SlantedColumnFailures.ColumnMustBeVertical == failId)
{
// This element must be vertical.
}