Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Jan 20, 2025
1 parent 2edcfc6 commit b501356
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 8 deletions.
38 changes: 30 additions & 8 deletions ricaun.Revit.DA/DesignApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@

namespace ricaun.Revit.DA
{
public abstract class DesignApplication<T> : DesignApplication where T : IDesignAutomation
{
public override bool Execute(Application application, string filePath, Document document)
{
return Activator.CreateInstance<T>().Execute(application, filePath, document);
}
}

/// <summary>
/// Represents a design application that executes a specific type of design automation.
/// </summary>
public abstract class DesignApplication : IExternalDBApplication, IDesignAutomation
{
/// <summary>
Expand All @@ -25,13 +20,35 @@ public abstract class DesignApplication : IExternalDBApplication, IDesignAutomat
/// Use DesignApplicationLoader to load the correct version of the DesignApplication based in the `PackageContents.xml` configuration.
/// </summary>
public virtual bool UseDesignApplicationLoader => true;
/// <summary>
/// Gets the controlled application.
/// </summary>
public ControlledApplication ControlledApplication { get; private set; }
/// <summary>
/// Method called when the application starts up.
/// </summary>
public virtual void OnStartup() { }
/// <summary>
/// Method called when the application shuts down.
/// </summary>
public virtual void OnShutdown() { }
/// <summary>
/// Executes the design automation.
/// </summary>
/// <param name="application">The Revit application.</param>
/// <param name="filePath">The file path to the document.</param>
/// <param name="document">The Revit document.</param>
/// <returns>True if the execution is successful; otherwise, false.</returns>
public abstract bool Execute(Application application, string filePath, Document document);

private IExternalDBApplication designApplication;
private DesignAutomationSingleExternalServer externalServer;

/// <summary>
/// Method called when the application starts up.
/// </summary>
/// <param name="application">The controlled application.</param>
/// <returns>The result of the external DB application startup.</returns>
public ExternalDBApplicationResult OnStartup(ControlledApplication application)
{
ControlledApplication = application;
Expand Down Expand Up @@ -66,6 +83,11 @@ public ExternalDBApplicationResult OnStartup(ControlledApplication application)
return ExternalDBApplicationResult.Succeeded;
}

/// <summary>
/// Method called when the application shuts down.
/// </summary>
/// <param name="application">The controlled application.</param>
/// <returns>The result of the external DB application shutdown.</returns>
public ExternalDBApplicationResult OnShutdown(ControlledApplication application)
{
ControlledApplication = application;
Expand Down
25 changes: 25 additions & 0 deletions ricaun.Revit.DA/DesignApplicationT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using System;

namespace ricaun.Revit.DA
{
/// <summary>
/// Represents a design application that executes a specific type of design automation.
/// </summary>
/// <typeparam name="T">The type of design automation to execute.</typeparam>
public abstract class DesignApplication<T> : DesignApplication where T : IDesignAutomation
{
/// <summary>
/// Executes the design automation of type <typeparamref name="T"/>.
/// </summary>
/// <param name="application">The Revit application.</param>
/// <param name="filePath">The file path to the document.</param>
/// <param name="document">The Revit document.</param>
/// <returns>True if the execution is successful; otherwise, false.</returns>
public override bool Execute(Application application, string filePath, Document document)
{
return Activator.CreateInstance<T>().Execute(application, filePath, document);
}
}
}
10 changes: 10 additions & 0 deletions ricaun.Revit.DA/IDesignAutomation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@

namespace ricaun.Revit.DA
{
/// <summary>
/// Interface for design automation tasks in Revit.
/// </summary>
public interface IDesignAutomation
{
/// <summary>
/// Executes a design automation task.
/// </summary>
/// <param name="application">The Revit application instance.</param>
/// <param name="filePath">The file path to the document.</param>
/// <param name="document">The Revit document instance.</param>
/// <returns>True if the task was executed successfully, otherwise false.</returns>
bool Execute(Application application, string filePath, Document document);
}
}

0 comments on commit b501356

Please sign in to comment.