algorithmic modeling for Rhino
I don't follow. Can you elaborate more on what your code is supposed to achieve? Perhaps post the signature of the method you're trying to write?
--
David Rutten
david@mcneel.com
I think he means wild cards in the mask and [Split Tree]
{0;0;?} to get {0;0;0}, {0;0;1}
{1;1;?} to get {1;1;0}, {1;1;1}, {1;1;2}
{2;2;?} to get {2;2;0}
or
{0;*} to get {0;0;0}, {0;0;1}
{1;*} to get {1;1;0}, {1;1;1}, {1;1;2}
{2;*} to get {2;2;0}
More on Mask rules here: http://www.grasshopper3d.com/forum/topics/datatree-selection-rules
It was posted in the coding forum, so I figured he was after code... but this makes sense.
--
David Rutten
david@mcneel.com
Sorry I did notice this and meant to phrase my reply along the lines of "Like the Split Tree Component".... brain not engaged yet
You can use split tree logic, it is available through the Gh SDK, however this is such a simple case that you may as well write it from scratch. I'd ask again to see the signature of the function you're after, I don't know exactly how the paths are currently stored, what data is associated with them and how you want them in return.
--
David Rutten
david@mcneel.com
I have tree, with 3 depth for all branches.
Function get first two numbers for path. And return new tree with one level.
Function which I use, for describe logic.
private DataTree<Object> _GetData(DataTree<Object> data, int number1, int number2)
{
DataTree<Object> res = new DataTree<Object>();
string path = number1 + ";" + number2 + ";";if (number1 >= 0 && number2 >=0 )
for(int i = 0; i < data.BranchCount; i++) {
string str = data.Path(i).ToString().Trim(new char[] {'{', '}'});
string part = str.Substring(0, path.Length);
string idx = str.Substring(path.Length);
if (path.Equals(part))
for(int j = 0; j < data.Branch(i).Count; j++)
res.Add(data.Branch(i)[j], new GH_Path(Convert.ToInt32(idx)));
}
return res;
}
I loop all braches, get it's path and compare to string. Last number(variable idx) from branch path use for numbering result tree.
How I can simplify this function, use mask rules?
This would be my suggestion:
private DataTree<Object> GetBranches(DataTree<Object> data, params int[] pathStart)
{
GH_Path pathFilter = new GH_Path(pathStart);
DataTree<Object> result = new DataTree<Object>();
for (int i = 0; i < data.BranchCount; i++)
{
GH_Path path = data.Path(i);
List<Object> list = data.Branch(i);
int ad = 0;
if (path.IsAncestor(pathFilter, ref ad))
result.AddRange(list, path);
}
return result;
}
--
David Rutten
david@mcneel.com
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