Skip to content

Commit

Permalink
implemented OnApplicationInitialized application access and open mode…
Browse files Browse the repository at this point in the history
…l file
  • Loading branch information
jeremytammik committed Sep 26, 2018
1 parent be20c9b commit bd67e83
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions CS/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@
// (Rights in Technical Data and Computer Software), as applicable.
//

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.ApplicationServices;

namespace Revit.SDK.Samples.StairsAutomation.CS
{
/// <summary>
/// Implement the Revit add-in IExternalDBApplication interface
/// </summary>
[Transaction( TransactionMode.Manual )]
public class App : IExternalDBApplication
public class DbApp : IExternalDBApplication
{
string _model_path = "C:/a/vs/StairsAutomation/CS/Stairs_automation_2019_1.rvt";

/// <summary>
/// The implementation of the automatic stairs creation.
/// </summary>
public void Execute()
public void Execute( Document document )
{
//UIDocument activeDocument = commandData.Application.ActiveUIDocument;
Document document = null; // activeDocument.Document;
//Document document = activeDocument.Document;

// Create an automation utility with a hardcoded
// stairs configuration number
Expand All @@ -60,7 +61,19 @@ StairsAutomationUtility utility
void OnApplicationInitialized(
object sender, ApplicationInitializedEventArgs e )
{
Execute();
// Sender is an Application instance:

Application app = sender as Application;

Document doc = app.OpenDocumentFile( _model_path );

if( doc == null )
{
throw new InvalidOperationException(
"Could not open document." );
}

Execute( doc );
}

public ExternalDBApplicationResult OnStartup(
Expand Down

0 comments on commit bd67e83

Please sign in to comment.