本文整理汇总了C#中Document.PostFailure方法的典型用法代码示例。如果您正苦于以下问题:C# Document.PostFailure方法的具体用法?C# Document.PostFailure怎么用?C# Document.PostFailure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document.PostFailure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostFailure
public static void PostFailure(Document document, IEnumerable<Exception> exceptions)
{
var log = new ExceptionLog();
log.Add(exceptions);
log.SaveToFile(Paths.ErrorFile);
var msg = new FailureMessage(GeneralFailure);
document.PostFailure(msg);
}
示例2: IsFatalException
/// <summary>
/// Determines if the Exception is local to the element, or if export should be aborted.
/// </summary>
/// <param name="ex">The unexpected exception.</param>
public static bool IsFatalException(Document document, Exception exception)
{
string msg = exception.ToString();
if (msg.Contains("Error in allocating memory"))
{
FailureMessage fm = new FailureMessage(BuiltInFailures.ExportFailures.IFCFatalToolkitExportError);
document.PostFailure(fm);
return true;
}
return false;
}
示例3: PostDelayedLinkErrors
/// <summary>
/// Post any delayed errors or warnings to the current document.
/// </summary>
/// <remarks>Needs to occur inside of a transaction.</remarks>
public static void PostDelayedLinkErrors(Document doc)
{
if (m_ImportPostedErrors == null)
return;
try
{
foreach (FailureDefinitionId failureDefId in m_ImportPostedErrors)
{
FailureMessage fm = new FailureMessage(failureDefId);
doc.PostFailure(fm);
}
}
catch
{
}
finally
{
m_ImportPostedErrors = null;
}
}
示例4: Execute
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="commandData">An object that is passed to the external application
/// which contains data related to the command,
/// such as the application object and active view.</param>
/// <param name="message">A message that can be set by the external application
/// which will be displayed if a failure or cancellation is returned by
/// the external command.</param>
/// <param name="elements">A set of elements to which the external application
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
/// <returns>Return the status of the external command.
/// A result of Succeeded means that the API external method functioned as expected.
/// Cancelled can be used to signify that the user cancelled the external operation
/// at some point. Failure should be returned if the application is unable to proceed with
/// the operation.</returns>
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message, Autodesk.Revit.DB.ElementSet elements)
{
m_revitApp = commandData.Application.Application;
m_doc = commandData.Application.ActiveUIDocument.Document;
Level level1 = GetLevel();
if (level1 == null)
{
throw new Exception("[ERROR] Failed to get level 1");
}
try
{
//
// Post a warning and resolve it in FailurePreproccessor
try
{
Transaction transaction = new Transaction(m_doc, "Warning_FailurePreproccessor");
FailureHandlingOptions options = transaction.GetFailureHandlingOptions();
FailurePreproccessor preproccessor = new FailurePreproccessor();
options.SetFailuresPreprocessor(preproccessor);
transaction.SetFailureHandlingOptions(options);
transaction.Start();
FailureMessage fm = new FailureMessage(m_idWarning);
m_doc.PostFailure(fm);
transaction.Commit();
}
catch (System.Exception)
{
message = "Failed to commit transaction Warning_FailurePreproccessor";
return Result.Failed;
}
//
// Dismiss the overlapped wall warning in FailurePreproccessor
try
{
Transaction transaction = new Transaction(m_doc, "Warning_FailurePreproccessor_OverlappedWall");
FailureHandlingOptions options = transaction.GetFailureHandlingOptions();
FailurePreproccessor preproccessor = new FailurePreproccessor();
options.SetFailuresPreprocessor(preproccessor);
transaction.SetFailureHandlingOptions(options);
transaction.Start();
Line line = m_revitApp.Create.NewLineBound(new XYZ(-10, 0, 0), new XYZ(-20, 0, 0));
Wall wall1 = m_doc.Create.NewWall(line, level1, false);
Wall wall2 = m_doc.Create.NewWall(line, level1, false);
m_doc.Regenerate();
transaction.Commit();
}
catch (System.Exception)
{
message = "Failed to commit transaction Warning_FailurePreproccessor_OverlappedWall";
return Result.Failed;
}
//
// Post an error and resolve it in FailuresProcessingEvent
try
{
m_revitApp.FailuresProcessing += new EventHandler<Autodesk.Revit.DB.Events.FailuresProcessingEventArgs>(FailuresProcessing);
Transaction transaction = new Transaction(m_doc, "Error_FailuresProcessingEvent");
transaction.Start();
Line line = m_revitApp.Create.NewLineBound(new XYZ(0, 10, 0), new XYZ(20, 10, 0));
Wall wall = m_doc.Create.NewWall(line, level1, false);
m_doc.Regenerate();
FailureMessage fm = new FailureMessage(m_idError);
FailureResolution fr = DeleteElements.Create(m_doc, wall.Id);
fm.AddResolution(FailureResolutionType.DeleteElements, fr);
m_doc.PostFailure(fm);
transaction.Commit();
}
catch (System.Exception)
{
message = "Failed to commit transaction Error_FailuresProcessingEvent";
return Result.Failed;
}
//
// Post an error and resolve it in FailuresProcessor
//.........这里部分代码省略.........