algorithmic modeling for Rhino
Hi,
I have input in the component of as guid.
IGH_Param geometryAsGuid = new Grasshopper.Kernel.Parameters.Param_Guid();
pManager.AddParameter(geometryAsGuid, "Guid", "Guid", "Guid", GH_ParamAccess.list);
I would like to flatten all inputs. For now I am doing it like this:
pManager[0].DataMapping = GH_DataMapping.Flatten;
Is there other way to get all inputs?
Tags:
Yess...
The issue was that
I did declare default parameter:
pManager.AddNumberParameter("RotationMin", "RotationMin", "Rotation domain start value", GH_ParamAccess.item, 25);
Without 25 it works:) Thank you.
Is it possible to attach other kind of components such as plane, guid boolean toggles and ect?
If the slider is detached, how can I still have default value?
And the correct way of looping is this?
public override void AddedToDocument(GH_Document document)
{
base.AddedToDocument(document);
for (int i = 0; i < 2; i++)
{
Param_Number numberInput = Params.Input[i+2] as Param_Number;
if (numberInput == null) return;
if (numberInput.SourceCount > 0) return;
if (numberInput.PersistentDataCount > 0) return;
Attributes.PerformLayout();
int x = (int)numberInput.Attributes.Pivot.X - 250;
int y = (int)numberInput.Attributes.Pivot.Y - 10;
GH_NumberSlider slider = new GH_NumberSlider();
slider.SetInitCode("0.00<180.00<180.00");
slider.CreateAttributes();
slider.Attributes.Pivot = new PointF(x, y);
slider.Attributes.ExpireLayout();
document.AddObject(slider, false);
numberInput.AddSource(slider);
}
}
You can attach whatever you like. As long as the component is defined inside an assembly you reference, or if you know the ComponentID of it so you can ask Grasshopper to make one for you.
What I am doing wrong when adding guid parameter:
Param_Guid gInput = Params.Input[0] as Param_Guid;
if (gInput == null) return;
if (gInput.SourceCount > 0) return;
if (gInput.PersistentDataCount > 0) return;
Attributes.PerformLayout();
int xG = (int)gInput.Attributes.Pivot.X - 250;
int yG = (int)gInput.Attributes.Pivot.Y - 10;
IGH_Param guid = new Grasshopper.Kernel.Parameters.Param_Guid();
guid.CreateAttributes();
guid.Attributes.Pivot = new PointF(xG,yG);
guid.Attributes.ExpireLayout();
document.AddObject(guid, false);
gInput.AddSource(gInput);
gInput.AddSource(gInput);
You cannot add a source to a parameter that is the same parameter.
Should be:
gInput.AddSource(guid);
Hi,
When defining this custom parameter, is there any chance I can add default value, if input is deleted/disconnected from main component.
Now I have this:
Param_Number numberInput = Params.Input[i + 2] as Param_Number;
if (numberInput == null) return;
if (numberInput.SourceCount > 0) return;
if (numberInput.PersistentDataCount > 0) return;
Attributes.PerformLayout();
int x = (int)numberInput.Attributes.Pivot.X - 250;
int y = (int)numberInput.Attributes.Pivot.Y - 10;
GH_NumberSlider slider = new GH_NumberSlider();
slider.SetInitCode("0.0<" + values[i] + "<" + endValues[i]);
slider.CreateAttributes();
slider.Attributes.Pivot = new PointF(x, y);
slider.Attributes.ExpireLayout();
document.AddObject(slider, false);
numberInput.AddSource(slider);
But what I want to add is this number in bold as default value:
pManager.AddNumberParameter("ScaleXMax", "X2", "ScaleX domain end value", GH_ParamAccess.item, 10.9458526526262626886);
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by