Launch OpenFileDialog in OnStartup

Launch OpenFileDialog in OnStartup

tom_flaherty
Participant Participant
247 Views
1 Reply
Message 1 of 2

Launch OpenFileDialog in OnStartup

tom_flaherty
Participant
Participant

Is it possible to launch an instance o OpenFileDialog during OnStartup? Essentially, I'm attempting to create a custom start up interface. First I prompt the user to select if they are wanting to start a new project or work on an existing project. If they select New, my Create New Project form launches, and based on the user inputs, a new project is created, based on a particular template, it is saved in a location determined by the user inputs, and then opened and made the active document. if the user selects Existing, I want the open File Dialog to launch letting them navigate to the file they want to work on. If the user hits cancel on the initial form, Revit should continue to open and take the user to the Home screen.

0 Likes
248 Views
1 Reply
Reply (1)
Message 2 of 2

ricaun
Advisor
Advisor

Stop the OnStartup looks like a bad idea. Your application is going to stop the other plugin from starting and I'm not sure if your app is able to Open a document, Revit didn't finish the initialization.

 

You should move the code to the ApplicationInitialized (https://www.revitapidocs.com/2016/1d917597-712c-cec3-db2a-8301c62a8ee3.htm) event, or even better to the Idling (https://www.revitapidocs.com/2015/56145d84-e948-730a-dc72-2a7b88a50a99.htm) event.

 

In the Idling gonna execute when Revit is ready to receive some user input.

 

Here is a simple sample:

public class App : IExternalApplication
{
    public Result OnStartup(UIControlledApplication application)
    {
        application.Idling += Application_Idling;
        return Result.Succeeded;
    }

    public Result OnShutdown(UIControlledApplication application)
    {
        application.Idling -= Application_Idling;
        return Result.Succeeded;
    }

    private static void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
    {
        var uiapp = sender as UIApplication;
        uiapp.Idling -= Application_Idling;

        TaskDialog.Show("Title", "Message");
    }
}

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes