public static void BakeSelectedComponents()
        {
            var canvas     = Grasshopper.Instances.ActiveCanvas;
            var definition = canvas?.Document;

            if (definition == null)
            {
                return;
            }

            var bakeProperties = new BakeDialog();

            if (bakeProperties.ShowDialog(Grasshopper.Instances.DocumentEditor) != DialogResult.OK)
            {
                return;
            }

            bool needExpire = false;

            foreach (var obj in definition.Objects.OfType <BakeComponent>())
            {
                if (obj.Locked || !obj.Attributes.Selected)
                {
                    continue;
                }

                needExpire = true;
                Expire(obj, bakeProperties);
            }
            if (needExpire)
            {
                GhDrawingContext.LinkedDocument?.Database?.StartUndoRecord();
                definition.NewSolution(false);
            }
        }
 public static void Expire(BakeComponent bakeComponent, BakeDialog bakeProperties)
 {
     bakeComponent._needBake = true;
     bakeComponent._color    = bakeProperties.Color;
     bakeComponent._layer    = bakeProperties.Layer;
     bakeComponent._material = bakeProperties.Material;
     bakeComponent.ExpireSolution(false);
 }
        private void BakeItemCall(object sender, EventArgs e)
        {
            var bakeProperties = new BakeDialog();

            if (bakeProperties.ShowDialog(Grasshopper.Instances.DocumentEditor) == DialogResult.OK)
            {
                _color    = bakeProperties.Color;
                _layer    = bakeProperties.Layer;
                _material = bakeProperties.Material;
                _needBake = true;

                GhDrawingContext.LinkedDocument?.Database?.StartUndoRecord();
                ExpireSolution(true);
            }
        }