algorithmic modeling for Rhino
Hello everyone,
I'd like to refer DataTree<double> parameter that connected left side of GH Component.
Usually, I succeeded in private void RunScript(DataTree<double> Input, ref object Output)
There is no need to think this.
But I failed to refer in custom additional code area.
Is there anyone knows how to refer input parameters between //custom additional code//?
Sorry for my poor knowledge of C#.....
Best,
Shimpei
Tags:
I don't understand. Whatever code you write in the additional block is necessarily in a different method than the RunScript method. As such that code will have to be encapsulated in a method signature of your own devising. You can choose whatever arguments you want for these methods. For example:
private void DoSomething(DataTree<double> data, double min, double max)
{
for (int p = 0; p < data.BranchCount; p++)
{
List<double> branch = data.Branch(p);
for (int i = 0; i < branch.Count; i++)
branch[i] = Math.Min(Math.Max(branch[i], min), max);
}
}
Dear David,
Thank you for your answer.
I made mistake to explain what I struggle.
I want to make global value in the additional block like this
And, I attach my .gh file.
private void RunScript(DataTree<double> Input, ref object A)
{
etc...
}
// <Custom additional code>
//refering global value
public int num = 4;
public int nnode = (int) Input.Branch(new GH_Path(0))[0];
public int nelem = (int) Input.Branch(new GH_Path(1))[0];
public int nmat = (int) Input.Branch(new GH_Path(2))[0];
public int nprop = (int) Input.Branch(new GH_Path(3))[0];
// </Custom additional code>
I don't think you can set Input to be a 'global' value (a class wide variable), since it is defined as an input of the method runscript.
But, what you can do is create a declaring another Datatree<double> outside of the method and copying Input into it.
Would that help?
private void RunScript(DataTree<int> x, ref object A)
{
y = x;
// Do Whatever you want here
A = y;
}
// <Custom additional code>
DataTree<int> y;
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
© 2024 Created by Scott Davidson. Powered by