Пример #1
0
        public DynamoController_Revit(FSchemeInterop.ExecutionEnvironment env, DynamoUpdater updater, Type viewModelType, string context)
            : base(env, viewModelType, context)
        {
            Updater = updater;

            dynRevitSettings.Controller = this;

            Predicate <NodeModel> requiresTransactionPredicate = node => node is RevitTransactionNode;

            CheckRequiresTransaction = new PredicateTraverser(requiresTransactionPredicate);

            Predicate <NodeModel> manualTransactionPredicate = node => node is Transaction;

            CheckManualTransaction = new PredicateTraverser(manualTransactionPredicate);

            dynSettings.Controller.DynamoViewModel.RequestAuthentication += RegisterSingleSignOn;

            AddPythonBindings();
            AddWatchNodeHandler();

            dynRevitSettings.Revit.Application.DocumentClosed += Application_DocumentClosed;
            dynRevitSettings.Revit.Application.DocumentOpened += Application_DocumentOpened;
            dynRevitSettings.Revit.ViewActivated += Revit_ViewActivated;

            //allow the showing of elements in context
            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements    = FindNodesFromSelection;
        }
Пример #2
0
        public DynamoController_Revit(FSchemeInterop.ExecutionEnvironment env, DynamoUpdater updater, Type viewModelType, string context, IUnitsManager units)
            : base(env, viewModelType, context, new UpdateManager.UpdateManager(), units, new RevitWatchHandler(), Dynamo.PreferenceSettings.Load())
        {
            Updater = updater;

            dynRevitSettings.Controller = this;

            Predicate <NodeModel> requiresTransactionPredicate = node => node is RevitTransactionNode;

            CheckRequiresTransaction = new PredicateTraverser(requiresTransactionPredicate);

            Predicate <NodeModel> manualTransactionPredicate = node => node is Transaction;

            CheckManualTransaction = new PredicateTraverser(manualTransactionPredicate);

            dynSettings.Controller.DynamoViewModel.RequestAuthentication += RegisterSingleSignOn;

            AddPythonBindings();

            dynRevitSettings.Revit.Application.DocumentClosed += Application_DocumentClosed;
            dynRevitSettings.Revit.Application.DocumentOpened += Application_DocumentOpened;
            dynRevitSettings.Revit.ViewActivated += Revit_ViewActivated;

            //allow the showing of elements in context
            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements    = FindNodesFromSelection;

            MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrationsRevit));
            ElementNameStore = new Dictionary <ElementId, string>();
        }
Пример #3
0
        private void Init(IUpdateManager updateManager)
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve;

            var env = new ExecutionEnvironment();
            Controller = new DynamoController(env, typeof(DynamoViewModel), "None", null, updateManager, new UnitsManager())
            {
                Testing = true
            };

            //create the view
            Ui = new DynamoView { DataContext = Controller.DynamoViewModel };
            Vm = Controller.DynamoViewModel;
            Controller.UIDispatcher = Ui.Dispatcher;
            Ui.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            string tempPath = Path.GetTempPath();
            TempFolder = Path.Combine(tempPath, "dynamoTmp");

            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }
            else
            {
                EmptyTempFolder();
            }
        }
Пример #4
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(ExecutionEnvironment env)
        {
            dynSettings.Controller = this;

            this.RunEnabled = true;
            this.CanRunDynamically = true;

            Bench = new dynBench(this);
            dynSettings.Bench = Bench;

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeLoader = new CustomNodeLoader(pluginsPath);

            SearchViewModel = new SearchViewModel();
            PackageManagerClient = new PackageManagerClient(this);
            PackageManagerLoginViewModel = new PackageManagerLoginViewModel(PackageManagerClient);
            PackageManagerPublishViewModel = new PackageManagerPublishViewModel(PackageManagerClient);

            FSchemeEnvironment = env;

            HomeSpace = CurrentSpace = new HomeWorkspace();
            Bench.CurrentOffset = new Point(dynBench.CANVAS_OFFSET_X, dynBench.CANVAS_OFFSET_Y);

            Bench.InitializeComponent();
            Bench.Log(String.Format(
                "Dynamo -- Build {0}.",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.LoadBuiltinTypes(SearchViewModel, this, Bench);
            DynamoLoader.LoadSamplesMenu(Bench);

            Bench.settings_curves.IsChecked = true;
            Bench.settings_curves.IsChecked = false;

            Bench.LockUI();

            Bench.Activated += OnBenchActivated;
            dynSettings.Workbench = Bench.WorkBench;

            //run tests
            if (FScheme.RunTests(Bench.Log))
            {
                if (Bench != null)
                    Bench.Log("All Tests Passed. Core library loaded OK.");
            }
        }
Пример #5
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(ExecutionEnvironment env, Type viewModelType, string context)
        {
            dynSettings.Controller = this;

            this.Context = context;

            //create the view model to which the main window will bind
            //the DynamoModel is created therein
            this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(viewModelType,new object[]{this});

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);

            SearchViewModel = new SearchViewModel();
            PackageManagerClient = new PackageManagerClient();
            dynSettings.PackageManagerClient = PackageManagerClient;
            PublishPackageViewModel = new PublishPackageViewModel(PackageManagerClient);

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            FSchemeEnvironment = env;

            DynamoViewModel.Model.CurrentSpace.X = DynamoView.CANVAS_OFFSET_X;
            DynamoViewModel.Model.CurrentSpace.Y = DynamoView.CANVAS_OFFSET_Y;

            dynSettings.Controller.DynamoViewModel.Log(String.Format(
                "Dynamo -- Build {0}",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadBuiltinTypes();

            //run tests
            if (FScheme.RunTests(dynSettings.Controller.DynamoViewModel.Log))
            {
                dynSettings.Controller.DynamoViewModel.Log("All Tests Passed. Core library loaded OK.");
            }

            NodeSubmittedForRendering += new EventHandler(Controller_NodeSubmittedForRendering);
            NodeRemovedFromRendering += new EventHandler(Controller_NodeRemovedFromRendering);
        }
Пример #6
0
        public DynamoController_Revit(FSchemeInterop.ExecutionEnvironment env, DynamoUpdater updater, Type viewModelType, string context)
            : base(env, viewModelType, context)
        {
            Updater = updater;

            dynRevitSettings.Controller = this;

            //AppDomain currentDomain = AppDomain.CurrentDomain;
            //currentDomain.AssemblyResolve += ResolveSSONETHandler;

            dynSettings.PackageManagerClient.AuthenticationRequested += RegisterSingleSignOn;

            AddPythonBindings();
            AddWatchNodeHandler();

            dynRevitSettings.Revit.Application.DocumentClosed += Application_DocumentClosed;
            dynRevitSettings.Revit.Application.DocumentOpened += Application_DocumentOpened;

            //allow the showing of elements in context
            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.CanFindNodesFromElements = true;
            dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.FindNodesFromElements    =
                new Action(FindNodesFromSelection);
        }
Пример #7
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(ExecutionEnvironment env, bool withUI, Type viewModelType, string context)
        {
            dynSettings.Controller = this;

            this.Context = context;

            //MVVM: don't construct the main window with a reference to the controller
            //dynSettings.Bench = new dyndynSettings.Bench(this);

            //MVVM : create the view model to which the main window will bind
            //the DynamoModel is created therein
            //this.DynamoViewModel = new DynamoViewModel(this);
            this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(viewModelType,new object[]{this});

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeLoader = new CustomNodeLoader(pluginsPath);

            if (withUI)
            {
                dynSettings.Bench = new DynamoView();
                dynSettings.Bench = dynSettings.Bench;
                dynSettings.Bench.DataContext = DynamoViewModel;
            }

            SearchViewModel = new SearchViewModel();
            PackageManagerClient = new PackageManagerClient(this);
            PackageManagerLoginViewModel = new PackageManagerLoginViewModel(PackageManagerClient);
            PackageManagerPublishViewModel = new PackageManagerPublishViewModel(PackageManagerClient);

            FSchemeEnvironment = env;

            //MVVM : moved to proper view constructor on dyndynSettings.Bench
            //DynamoViewModel.Model.CurrentSpace.CurrentOffset = new Point(DynamoView.CANVAS_OFFSET_X, DynamoView.CANVAS_OFFSET_Y);
            DynamoViewModel.Model.CurrentSpace.X = DynamoView.CANVAS_OFFSET_X;
            DynamoViewModel.Model.CurrentSpace.Y = DynamoView.CANVAS_OFFSET_Y;

            //dynSettings.Bench.CurrentOffset = new Point(dyndynSettings.Bench.CANVAS_OFFSET_X, dyndynSettings.Bench.CANVAS_OFFSET_Y);
            //dynSettings.Bench.InitializeComponent();

            dynSettings.Controller.DynamoViewModel.Log(String.Format(
                "Dynamo -- Build {0}.",
                Assembly.GetExecutingAssembly().GetName().Version));

            //MVVM : removed parameter dynSettings.Bench
            DynamoLoader.LoadBuiltinTypes(SearchViewModel, this);//, dynSettings.Bench);

            if(dynSettings.Bench != null)
                DynamoLoader.LoadSamplesMenu(dynSettings.Bench);

            //dynSettings.Bench.settings_curves.IsChecked = true;
            //dynSettings.Bench.settings_curves.IsChecked = false;

            if (dynSettings.Bench != null)
            {
                //dynSettings.Bench.LockUI();

                //MVVM : callback has been restructured so that it sends a command back to the view model
                //dynSettings.Bench.Activated += OndynSettings.BenchActivated;

                //MVVM: we've gone to using a model and a model view of a workspace
                //do not reference a specific workdynSettings.Bench here.
                //dynSettings.WorkdynSettings.Bench = dynSettings.Bench.WorkdynSettings.Bench;
            }

            //run tests
            if (FScheme.RunTests(dynSettings.Controller.DynamoViewModel.Log))
            {
                if (dynSettings.Bench != null)
                    this.DynamoViewModel.Log("All Tests Passed. Core library loaded OK.");
            }
        }
Пример #8
0
 public DynamoController(ExecutionEnvironment env, Type viewModelType, string context)
     : this(env, viewModelType, context, null)
 {
 }
Пример #9
0
        public static DynamoController MakeSandbox(string commandFilePath = null)
        {
            ExecutionEnvironment env = new ExecutionEnvironment();

            // If a command file path is not specified or if it is invalid, then fallback.
            if (string.IsNullOrEmpty(commandFilePath) || (File.Exists(commandFilePath) == false))
                return new DynamoController(env, typeof(DynamoViewModel), "None");

            return new DynamoController(env, typeof(DynamoViewModel), "None", commandFilePath);
        }
Пример #10
0
        /// <summary>
        ///     Class constructor
        /// </summary>
        public DynamoController(ExecutionEnvironment env,
            Type viewModelType, string context, string commandFilePath)
        {
            DynamoLogger.Instance.StartLogging();

            dynSettings.Controller = this;

            this.Context = context;

            //Start heartbeat reporting
            Services.InstrumentationLogger.Start();

            //create the view model to which the main window will bind
            //the DynamoModel is created therein
            this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(
                viewModelType, new object[] { this, commandFilePath });

            // custom node loader
            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string pluginsPath = Path.Combine(directory, "definitions");

            CustomNodeManager = new CustomNodeManager(pluginsPath);

            SearchViewModel = new SearchViewModel();

            dynSettings.PackageLoader = new PackageLoader();

            dynSettings.PackageLoader.DoCachedPackageUninstalls();
            dynSettings.PackageLoader.LoadPackages();

            FSchemeEnvironment = env;

            DynamoViewModel.Model.CurrentWorkspace.X = 0;
            DynamoViewModel.Model.CurrentWorkspace.Y = 0;

            DynamoLogger.Instance.Log(String.Format(
                "Dynamo -- Build {0}",
                Assembly.GetExecutingAssembly().GetName().Version));

            DynamoLoader.ClearCachedAssemblies();
            DynamoLoader.LoadBuiltinTypes();

            //run tests
            if (FScheme.RunTests(DynamoLogger.Instance.Log))
            {
                DynamoLogger.Instance.Log("All Tests Passed. Core library loaded OK.");
            }

            this.InfoBubbleViewModel = new InfoBubbleViewModel();

            AddPythonBindings();

            MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations));

            var updateManager = UpdateManager.UpdateManager.Instance;
            updateManager.UpdateDownloaded += updateManager_UpdateDownloaded;
            updateManager.ShutdownRequested += updateManager_ShutdownRequested;
            updateManager.CheckForProductUpdate();
        }
Пример #11
0
        public static DynamoController MakeSandbox(string commandFilePath = null)
        {
            var env = new ExecutionEnvironment();

            // If a command file path is not specified or if it is invalid, then fallback.
            if (string.IsNullOrEmpty(commandFilePath) || (File.Exists(commandFilePath) == false))
                return new DynamoController(env, typeof(DynamoViewModel), "None", new UpdateManager.UpdateManager(), new UnitsManager(), new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load());

            return new DynamoController(env, typeof(DynamoViewModel), "None", commandFilePath, new UpdateManager.UpdateManager(), new UnitsManager(), new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load());
        }
Пример #12
0
 public DynamoController(ExecutionEnvironment env, Type viewModelType, string context, IUpdateManager updateManager, IUnitsManager units, IWatchHandler watchHandler, IPreferences preferences)
     : this(env, viewModelType, context, null, updateManager, units, watchHandler, preferences)
 {
 }
Пример #13
0
 /// <summary>
 ///     Class constructor
 /// </summary>
 /// <param name="dynamoModel"> The parent DynamoModel object</param>
 /// <param name="fschemeEnv"> The enviro.  Should be able to get rid of this. </param>
 public DynamoRunner(DynamoModel dynamoModel, ExecutionEnvironment fschemeEnv)
 {
     this.DynamoModel = dynamoModel;
     this.FSchemeEnv = fschemeEnv;
 }
Пример #14
0
        public void CompileAndAddToEnvironment(ExecutionEnvironment env)
        {
            var compiledFunction = this.Compile();

            env.DefineSymbol( this.FunctionId.ToString(),compiledFunction);
        }
Пример #15
0
        private Expression evalIfDirty(FSharpList<Expression> args, ExecutionEnvironment environment)
        {
            //If this node requires a re-calc or if we haven't calc'd yet...
            if (this.IsDirty || this.oldValue == null)
            {
                //Store the environment
                this.macroEnvironment = environment;

                //Evaluate arguments, then evaluate this.
                this.oldValue = this.eval(
                   Utils.convertSequence(
                      args.Select(
                         input => environment.Evaluate(input)
                      )
                   )
                );
            }
            else //Otherwise, just increment the run counter.
                this.runCount++;

            //We're done here
            return this.oldValue;
        }
Пример #16
0
 public DynamoController(ExecutionEnvironment env, Type viewModelType, string context, IUpdateManager updateManager, IUnitsManager units)
     : this(env, viewModelType, context, null, updateManager, units)
 {
 }
Пример #17
0
        public DynamoController(SplashScreen splash)
        {
            Bench = new dynBench(this);

            splashScreen = splash;
            homeSpace = CurrentSpace = new HomeWorkspace();

            Bench.CurrentX = dynBench.CANVAS_OFFSET_X;
            Bench.CurrentY = dynBench.CANVAS_OFFSET_Y;

            Bench.InitializeComponent();
            Bench.Log(String.Format(
                "Dynamo -- Build {0}.",
                Assembly.GetExecutingAssembly().GetName().Version.ToString()));

            //WTF
            Bench.settings_curves.IsChecked = true;
            Bench.settings_curves.IsChecked = false;

            dynSettings.Bench = Bench;
            dynSettings.Controller = this;
            dynSettings.Workbench = Bench.WorkBench;

            Bench.LockUI();

            //run tests
            if (FScheme.RunTests(Bench.Log))
                Bench.Log("All Tests Passed. Core library loaded OK.");

            FSchemeEnvironment = new ExecutionEnvironment();

            LoadBuiltinTypes();
            PopulateSamplesMenu();

            Bench.Activated += Bench_Activated;
        }
Пример #18
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                //TAF load english_us TODO add a way to localize
                res = Resource_en_us.ResourceManager;
                // Create new ribbon panel
                RibbonPanel ribbonPanel = application.CreateRibbonPanel(res.GetString("App_Description"));

                //Create a push button in the ribbon panel
                var pushButton = ribbonPanel.AddItem(new PushButtonData("Dynamo",
                                                                        res.GetString("App_Name"), m_AssemblyName,
                                                                        "Dynamo.Applications.DynamoRevit")) as
                                 PushButton;

                Bitmap dynamoIcon = Resources.logo_square_32x32;

                BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
                    dynamoIcon.GetHbitmap(),
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());

                pushButton.LargeImage = bitmapSource;
                pushButton.Image = bitmapSource;

                IdlePromise.RegisterIdle(application);

                Updater = new DynamoUpdater(application.ActiveAddInId, application.ControlledApplication);
                if (!UpdaterRegistry.IsUpdaterRegistered(Updater.GetUpdaterId()))
                    UpdaterRegistry.RegisterUpdater(Updater);

                var SpatialFieldFilter = new ElementClassFilter(typeof (SpatialFieldManager));
                var familyFilter = new ElementClassFilter(typeof (FamilyInstance));
                var refPointFilter = new ElementCategoryFilter(BuiltInCategory.OST_ReferencePoints);
                var modelCurveFilter = new ElementClassFilter(typeof (CurveElement));
                var sunFilter = new ElementClassFilter(typeof (SunAndShadowSettings));
                IList<ElementFilter> filterList = new List<ElementFilter>();

                filterList.Add(SpatialFieldFilter);
                filterList.Add(familyFilter);
                filterList.Add(modelCurveFilter);
                filterList.Add(refPointFilter);
                filterList.Add(sunFilter);

                ElementFilter filter = new LogicalOrFilter(filterList);

                UpdaterRegistry.AddTrigger(Updater.GetUpdaterId(), filter, Element.GetChangeTypeAny());
                UpdaterRegistry.AddTrigger(Updater.GetUpdaterId(), filter, Element.GetChangeTypeElementDeletion());
                UpdaterRegistry.AddTrigger(Updater.GetUpdaterId(), filter, Element.GetChangeTypeElementAddition());

                env = new ExecutionEnvironment();

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return Result.Failed;
            }
        }
Пример #19
0
        //public DynamoController(SplashScreen splash)
        public DynamoController()
        {
            Bench = new dynBench(this);

            homeSpace = CurrentSpace = new HomeWorkspace();

            Bench.CurrentX = dynBench.CANVAS_OFFSET_X;
            Bench.CurrentY = dynBench.CANVAS_OFFSET_Y;

            Bench.InitializeComponent();
            Bench.Log(String.Format(
                "Dynamo -- Build {0}.",
                Assembly.GetExecutingAssembly().GetName().Version.ToString()));

            dynSettings.Bench = Bench;
            dynSettings.Controller = this;
            dynSettings.Workbench = Bench.WorkBench;

            if (DynamoCommands.ShowSplashScreenCmd.CanExecute(null))
            {
                DynamoCommands.ShowSplashScreenCmd.Execute(null);
            }

            //WTF
            Bench.settings_curves.IsChecked = true;
            Bench.settings_curves.IsChecked = false;

            Bench.LockUI();

            //run tests
            if (FScheme.RunTests(Bench.Log))
                Bench.Log("All Tests Passed. Core library loaded OK.");

            FSchemeEnvironment = new ExecutionEnvironment();

            LoadBuiltinTypes();
            PopulateSamplesMenu();

            Bench.Activated += Bench_Activated;

            //Dispatcher.CurrentDispatcher.Hooks.DispatcherInactive += new EventHandler(Hooks_DispatcherInactive);
        }