Esempio n. 1
0
        public static void BakeGhData()
        {
            var editor    = Application.DocumentManager.MdiActiveDocument.Editor;
            var selection = editor.GetSelection();

            if (selection.Status != PromptStatus.OK)
            {
                return;
            }

            var database     = editor.Document.Database;
            var ghDataToBake = new List <ObjectId>();

            using (var transaction = database.TransactionManager.StartTransaction())
            {
                for (int i = 0; i < selection.Value.Count; ++i)
                {
                    var entity = transaction.GetObject(selection.Value[i].ObjectId, OpenMode.ForRead) as Entity;
                    var id     = GrasshopperData.GetGrasshopperData(entity);
                    if (!id.IsNull)
                    {
                        ghDataToBake.Add(id);
                    }
                }
                transaction.Commit();
            }

            if (ghDataToBake.Count == 0)
            {
                return;
            }

            var bakeProperties = new UI.BakeDialog();

            if (bakeProperties.ShowDialog() != _WF.DialogResult.OK)
            {
                return;
            }

            var docExt = GhBcConnection.GrasshopperDataExtension.GrasshopperDataManager(Application.DocumentManager.MdiActiveDocument, true);

            docExt?.Bake(ghDataToBake, bakeProperties);
        }