Beispiel #1
0
        private void UpdateDrawable(GrasshopperData grasshopperData)
        {
            if (!grasshopperData.IsVisible)
            {
                return;
            }

            var definition = DefinitionManager.Definition(grasshopperData.Definition);

            if (definition == null)
            {
                return;
            }

            GrasshopperPlayer.Run(definition, grasshopperData, Document);
            var newDrawable = new CompoundDrawable
            {
                Color         = GhDataSettings.Color,
                ColorSelected = GhDataSettings.Color,
                IsRenderMode  = GhDataSettings.VisualStyle == GH_PreviewMode.Shaded
            };

            GrasshopperPreview.GetPreview(definition, newDrawable);
            definition.Dispose();
            _grasshopperData[grasshopperData.ObjectId] = newDrawable;
        }
Beispiel #2
0
        public bool AddGrasshopperData(GrasshopperData grasshopperData)
        {
            var objId = grasshopperData.ObjectId;

            if (objId.IsNull || _grasshopperData.ContainsKey(objId))
            {
                return(false);
            }

            DefinitionManager.Load(grasshopperData.Definition, new string[] { DwgPath });
            var definition = DefinitionManager.Definition(grasshopperData.Definition);

            if (definition == null)
            {
                return(false);
            }

            foreach (var param in GrasshopperPlayer.GetInputParametersValues(definition))
            {
                if (param.Item2 is Type type)
                {
                    grasshopperData.AddProperty(param.Item1, type);
                }
                else
                {
                    grasshopperData.AddProperty(param.Item1, param.Item2);
                }
            }
            definition.Dispose();
            return(true);
        }
Beispiel #3
0
        public void Bake(List <_OdDb.ObjectId> ghDataIds, UI.BakeDialog bakeProperties)
        {
            DisableReactors();
            var saveDoc = GhDrawingContext.LinkedDocument;

            GhDrawingContext.LinkedDocument = Document;
            using (var transaction = Document.Database.TransactionManager.StartTransaction())
            {
                using (var form = new UI.ModalForm())
                {
                    foreach (var ghDataId in ghDataIds)
                    {
                        var ghData = transaction.GetObject(ghDataId, _OdDb.OpenMode.ForRead) as GrasshopperData;
                        if (ghData == null)
                        {
                            continue;
                        }

                        var definition = DefinitionManager.Definition(ghData.Definition);
                        if (definition == null)
                        {
                            continue;
                        }

                        foreach (var obj in definition.Objects.OfType <Components.BakeComponent>())
                        {
                            if (!obj.Locked)
                            {
                                Components.BakeComponent.Expire(obj, bakeProperties);
                            }
                        }
                        GrasshopperPlayer.Run(definition, ghData, Document);
                    }
                }
                transaction.Commit();
            }
            GhDrawingContext.LinkedDocument = saveDoc;
            EnableReactors();
        }