Ejemplo n.º 1
0
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            DB.Element element = null;
            if (!DA.GetData("Element", ref element))
            {
                return;
            }

            IGH_Goo key = null;

            if (!DA.GetData("ParameterKey", ref key))
            {
                return;
            }

            var parameter = ParameterUtils.GetParameter(this, element, key);

            if (parameter is null)
            {
                return;
            }

            using (var transaction = NewTransaction(element.Document))
            {
                transaction.Start();

                if (parameter.ResetValue())
                {
                    if (CommitTransaction(element.Document, transaction) == DB.TransactionStatus.Committed)
                    {
                        DA.SetData("Element", element);
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Failed to reset '{parameter.Definition.Name}'");
                    }
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Unable to reset '{parameter.Definition.Name}'");
                }
            }
        }
Ejemplo n.º 2
0
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            DB.Element element = null;
            if (!DA.GetData("Element", ref element))
            {
                return;
            }

            IGH_Goo parameterKey = null;

            if (!DA.GetData("ParameterKey", ref parameterKey))
            {
                return;
            }

            var parameter = ParameterUtils.GetParameter(this, element, parameterKey);

            DA.SetData("ParameterValue", parameter);
        }
Ejemplo n.º 3
0
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            DB.Element element = null;
            if (!DA.GetData("Element", ref element))
            {
                return;
            }

            IGH_Goo key = null;

            if (!DA.GetData("ParameterKey", ref key))
            {
                return;
            }

            IGH_Goo value = null;

            if (!DA.GetData("ParameterValue", ref value))
            {
                return;
            }

            var parameter = ParameterUtils.GetParameter(this, element, key);

            if (parameter is null)
            {
                return;
            }

            StartTransaction(element.Document);

            if (ParameterUtils.SetParameter(this, parameter, value))
            {
                DA.SetData("Element", element);
            }
        }