Esempio n. 1
0
        private void StartDynamo()
        {
            try
            {
                // create the transaction manager object
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());

                DynamoRevit.InitializeUnits();

                var model = RevitDynamoModel.Start(
                    new RevitDynamoModel.StartConfiguration()
                {
                    StartInTestMode = true,
                    DynamoCorePath  = Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\..\")
                });

                this.ViewModel = DynamoViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    DynamoModel = model
                });

                // Because the test framework does not work in the idle thread.
                // We need to trick Dynamo into believing that it's in the idle
                // thread already.
                IdlePromise.InIdleThread = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
        public static DynamoRevitViewModel Start(StartConfiguration startConfiguration)
        {
            if (startConfiguration.DynamoModel == null)
            {
                startConfiguration.DynamoModel = RevitDynamoModel.Start();
            }
            else
            {
                if (startConfiguration.DynamoModel.GetType() != typeof(RevitDynamoModel))
                {
                    throw new Exception("An instance of RevitDynamoModel is required to construct a DynamoRevitViewModel.");
                }
            }

            if (startConfiguration.Watch3DViewModel == null)
            {
                startConfiguration.Watch3DViewModel =
                    HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                        null,
                        new Watch3DViewModelStartupParams(startConfiguration.DynamoModel),
                        startConfiguration.DynamoModel.Logger);
            }

            if (startConfiguration.WatchHandler == null)
            {
                startConfiguration.WatchHandler = new DefaultWatchHandler(startConfiguration.DynamoModel.PreferenceSettings);
            }

            return(new DynamoRevitViewModel(startConfiguration));
        }
        public static DynamoRevitViewModel Start(StartConfiguration startConfiguration)
        {
            if (startConfiguration.DynamoModel == null)
            {
                startConfiguration.DynamoModel = RevitDynamoModel.Start();
            }
            else
            {
                if (startConfiguration.DynamoModel.GetType() != typeof(RevitDynamoModel))
                {
                    throw new Exception("An instance of RevitDynamoViewModel is required to construct a DynamoRevitViewModel.");
                }
            }

            if (startConfiguration.VisualizationManager == null)
            {
                startConfiguration.VisualizationManager = new VisualizationManager(startConfiguration.DynamoModel);
            }

            if (startConfiguration.WatchHandler == null)
            {
                startConfiguration.WatchHandler = new DefaultWatchHandler(startConfiguration.VisualizationManager,
                                                                          startConfiguration.DynamoModel.PreferenceSettings);
            }

            return(new DynamoRevitViewModel(startConfiguration));
        }
Esempio n. 4
0
        private static RevitDynamoModel InitializeCoreModel(ExternalCommandData commandData)
        {
            var prefs    = PreferenceSettings.Load();
            var corePath =
                Path.GetFullPath(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\..\");

#if !ENABLE_DYNAMO_SCHEDULER
            return(RevitDynamoModel.Start(
                       new RevitDynamoModel.StartConfiguration()
            {
                Preferences = prefs,
                DynamoCorePath = corePath,
                Context = GetRevitContext(commandData)
            }));
#else
            return(RevitDynamoModel.Start(
                       new RevitDynamoModel.StartConfiguration()
            {
                Preferences = prefs,
                DynamoCorePath = corePath,
                Context = GetRevitContext(commandData),
                SchedulerThread = new RevitSchedulerThread(commandData.Application)
            }));
#endif
        }
Esempio n. 5
0
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            try
            {
                UpdateSystemPathForProcess();

                // create the transaction manager object
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());

                // Note that there is another data member pathResolver in base class
                // SystemTestBase. That pathResolver will be used only in StartDynamo
                // of the base class, here a local instance of pathResolver is used.
                //
                var revitTestPathResolver = new RevitTestPathResolver();
                revitTestPathResolver.InitializePreloadedLibraries();

                DynamoRevit.RevitDynamoModel = RevitDynamoModel.Start(
                    new RevitDynamoModel.RevitStartConfiguration()
                {
                    StartInTestMode       = true,
                    GeometryFactoryPath   = DynamoRevit.GetGeometryFactoryPath(testConfig.DynamoCorePath),
                    DynamoCorePath        = testConfig.DynamoCorePath,
                    PathResolver          = revitTestPathResolver,
                    Context               = "Revit 2014",
                    SchedulerThread       = new TestSchedulerThread(),
                    PackageManagerAddress = "https://www.dynamopackages.com",
                    ExternalCommandData   = new DynamoRevitCommandData(RevitTestExecutive.CommandData),
                    ProcessMode           = RevitTaskProcessMode
                });

                Model = DynamoRevit.RevitDynamoModel;

                this.ViewModel = DynamoRevitViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    DynamoModel = DynamoRevit.RevitDynamoModel,
                });

                var vm3D = ViewModel.Watch3DViewModels.FirstOrDefault(vm => vm is RevitWatch3DViewModel);
                if (vm3D != null)
                {
                    vm3D.Active = false;
                }

                // Because the test framework does not work in the idle thread.
                // We need to trick Dynamo into believing that it's in the idle
                // thread already.
                IdlePromise.InIdleThread = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            try
            {
                UpdateSystemPathForProcess();

                // create the transaction manager object
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());

                // Note that there is another data member pathResolver in base class
                // SystemTestBase. That pathResolver will be used only in StartDynamo
                // of the base class, here a local instance of pathResolver is used.
                //
                var commandData    = new DynamoRevitCommandData(RevitTestExecutive.CommandData);
                var userDataFolder = Path.Combine(Environment.GetFolderPath(
                                                      Environment.SpecialFolder.ApplicationData),
                                                  "Dynamo", "Dynamo Revit");
                var commonDataFolder = Path.Combine(Environment.GetFolderPath(
                                                        Environment.SpecialFolder.CommonApplicationData),
                                                    "Autodesk", "RVT " + commandData.Application.Application.VersionNumber, "Dynamo");

                // Set Path Resolver's user data folder and common data folder with DynamoRevit runtime.
                var pathResolverParams = new TestPathResolverParams()
                {
                    UserDataRootFolder   = userDataFolder,
                    CommonDataRootFolder = commonDataFolder
                };
                RevitTestPathResolver revitTestPathResolver = new RevitTestPathResolver(pathResolverParams);
                revitTestPathResolver.InitializePreloadedLibraries();

                // Get the preloaded DynamoRevit Custom Nodes, and Add them to Preload Libraries.
                var preloadedLibraries = new List <string>();
                GetLibrariesToPreload(preloadedLibraries);
                if (preloadedLibraries.Any())
                {
                    foreach (var preloadedLibrary in preloadedLibraries)
                    {
                        if (Directory.Exists(preloadedLibrary))
                        {
                            revitTestPathResolver.AddNodeDirectory(preloadedLibrary);
                        }
                        else if (File.Exists(preloadedLibrary))
                        {
                            revitTestPathResolver.AddPreloadLibraryPath(preloadedLibrary);
                        }
                    }
                }

                // Init DynamoTestPath to get DynamoSettings.xml which under user data folder
                PreferenceSettings.DynamoTestPath = string.Empty;
                //preload ASM and instruct dynamo to load that version of libG.
                var requestedLibGVersion = DynamoRevit.PreloadAsmFromRevit();

                DynamoRevit.RevitDynamoModel = RevitDynamoModel.Start(
                    new RevitDynamoModel.RevitStartConfiguration()
                {
                    StartInTestMode       = true,
                    GeometryFactoryPath   = DynamoRevit.GetGeometryFactoryPath(testConfig.DynamoCorePath, requestedLibGVersion),
                    DynamoCorePath        = testConfig.DynamoCorePath,
                    PathResolver          = revitTestPathResolver,
                    Context               = DynamoRevit.GetRevitContext(commandData),
                    SchedulerThread       = new TestSchedulerThread(),
                    PackageManagerAddress = "https://www.dynamopackages.com",
                    ExternalCommandData   = commandData,
                    ProcessMode           = RevitTaskProcessMode
                });

                Model = DynamoRevit.RevitDynamoModel;

                this.ViewModel = DynamoRevitViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                {
                    DynamoModel = DynamoRevit.RevitDynamoModel,
                });

                var vm3D = ViewModel.Watch3DViewModels.FirstOrDefault(vm => vm is RevitWatch3DViewModel);
                if (vm3D != null)
                {
                    vm3D.Active = false;
                }

                // Because the test framework does not work in the idle thread.
                // We need to trick Dynamo into believing that it's in the idle
                // thread already.
                IdlePromise.InIdleThread = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }