标签:back lin 屏蔽 -- pre gets exce erro img
public class BeeFaceFailureHandler : IFailuresPreprocessor { public string ErrorMessage { set; get; } public string ErrorSeverity { set; get; } public BeeFaceFailureHandler() { ErrorMessage = ""; ErrorSeverity = ""; } public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor) { IList<FailureMessageAccessor> failureMessages = failuresAccessor.GetFailureMessages(); foreach (FailureMessageAccessor failureMessageAccessor in failureMessages) { FailureDefinitionId id = failureMessageAccessor.GetFailureDefinitionId(); try { ErrorMessage = failureMessageAccessor.GetDescriptionText(); } catch { ErrorMessage = "Unknown Error"; } try { FailureSeverity failureSeverity = failureMessageAccessor.GetSeverity(); ErrorSeverity = failureSeverity.ToString(); if (failureSeverity == FailureSeverity.Warning) { //if (failureMessageAccessor.GetDescriptionText() == "同一位置处具有相同实例。这将导致在明细表中重复计算。.") //{ // List<ElementId> c = failureMessageAccessor.GetFailingElementIds().ToList(); // if (c.Count > 1) // { // failuresAccessor.DeleteElements(new List<ElementId>() { c[1] }); // } //} //else //{ // 如果是警告,则禁止消息框 failureMessageAccessor.GetDefaultResolutionCaption(); //} failuresAccessor.DeleteWarning(failureMessageAccessor); } else { // 如果是错误:则取消导致错误的操作,但是仍然继续整个事务 if (ErrorMessage.Contains("线太短")) { failureMessageAccessor.SetCurrentResolutionType(FailureResolutionType.DeleteElements); failuresAccessor.ResolveFailure(failureMessageAccessor); return FailureProcessingResult.ProceedWithCommit; } //else //{ // failuresAccessor.DeleteWarning(failureMessageAccessor); // return FailureProcessingResult.ProceedWithCommit; //} } } catch (Exception ex) { } } return FailureProcessingResult.Continue; } [Description("这个方法用在事务开始前,在FailureHandler初始化后调用")] /// <summary> /// 这个方法用在事务开始前,在FailureHandler初始化后调用 /// </summary> public static void SetFailedHandlerBeforeTransaction(IFailuresPreprocessor failureHandler, Transaction transaction) { FailureHandlingOptions failureHandlingOptions = transaction.GetFailureHandlingOptions(); failureHandlingOptions.SetFailuresPreprocessor(failureHandler); // 这句话是关键 //failureHandlingOptions.SetClearAfterRollback(true); transaction.SetFailureHandlingOptions(failureHandlingOptions); } }
调用方法:
Transaction tran = new Transaction(doc, "测试"); var failure = new BeeFaceFailureHandler(); BeeFaceFailureHandler.SetFailedHandlerBeforeTransaction(failure, tran); tran.Start(); //------- tran.Commit();
下面讲一下之前碰到的创建楼板的一个错误:边界边缘线彼此相交.边界等高线不可扭曲
解决方案:
1. 板的”结构“属性不要勾选,或者
2. 板的”启用分析模型“不要勾选
对应的,我们可以再创建floor之后,马上调用下面的任何一段代码:
1.floor.get_Parameter(BuiltInParameter.STRUCTURAL_ANALYTICAL_MODEL).Set(0);
2.floor.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL).Set(0);
如果不需要分析模型,请使用方法2,如果既不需要分析模型又不需要钢筋,请使用方法1.
标签:back lin 屏蔽 -- pre gets exce erro img
原文地址:https://www.cnblogs.com/mqxs/p/12785696.html