algorithmic modeling for Rhino
Hi guys,
I'm wondering if its possible to assign a default value to a list input. Let's say I just make a very simple component that creates a sphere from a list of points and doubles (the radius).
I would then have the input as:
pManager.AddPointParameter("Points", "P", "Base points for spheres", GH_ParamAccess.list);
pManager.AddNumberParameter("Radius", "R", "radius of sphere", GH_ParamAccess.list);
But what if I want to assign 10 as radius if nothing else is declared. If I had an item-input I would just write:
pManager.AddNumberParameter("Radius", "R", "radius of sphere", GH_ParamAccess.item, 10.0);
How does this work with lists?
Timo
Tags:
Hi Timo,
there's two different concepts here. "But what if I want to assign 10 as radius if nothing else is declared." refers to optional parameters. If there is no data, the SolveInstance method will just use 10 as a default. I don't think this is what you want.
You'll have to cast your parameter to Param_Number and populate the PersistentData:
Param_Number pR = pManager[1] as Param_Number;
pR.PersistentData.Append(new GH_Number(10.0));
--
David Rutten
david@mcneel.com
Seattle, WA
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
© 2025 Created by Scott Davidson.
Powered by