Esempio n. 1
0
        private static void InitializeCore(ExternalCommandData commandData)
        {
            if (initializedCore)
            {
                return;
            }

            IdlePromise.RegisterIdle(commandData.Application);
            InitializeAssemblies();
            InitializeUnits();
            InitializeDocumentManager(commandData);
            InitializeMigrationManager();

            initializedCore = true;
        }
Esempio n. 2
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);
            }
        }