Grasshopper

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

Views: 815

Replies to This Discussion

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

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service