How to add (or remove) points only on selected brances



Hi everyone,

I’m currently facing a challenge that seems straightforward but is proving tricky for me. I have a curve that I’ve divided into points. These points are then copied upward along the Z-axis by a fixed distance, creating 4 levels, and are also moved horizontally along the Y-axis by a variable distance.

I would like to adjust the levels as follows:

  • Branches 0-11 should have 6 levels,
  • Branches 12-21 should have 5 levels,
  • The remaining branches should stay at 4 levels.

I attempted to handle this with a Python component, but it only shifts the points upward, and the transitions are noticeable when I use these points to create boxes.

What would be the best approach to achieve this? Should I create 6 levels initially and then eliminate points where necessary, or start with 4 levels and add points as needed? Alternatively, is there a more efficient method to accomplish this?

Thanks for any advice!

Please attach something. A .gh with internalized data.

1 Like

As @maje90 mentioned, please share your file with geometry internalized so we can see whats going on.

Sounds like you may want to split your list at the desired branches then copy the partitioned list upward along the Z axis the desired number of times.

Hi @baileydw and @maje90
Here is the script and the additional picture of the problem.
240724_ZH_Curve.gh (32.6 KB)

I can not seems to load your python script.

@baileydw

Try copy paste this:

import Rhino.Geometry as rg
from Grasshopper import DataTree
from Grasshopper.Kernel.Data import GH_Path

Inputs

points_tree = points_tree # Data tree of points
height1 = height1 # Height for the first 14 branches
height2 = height2 # Height for the next 10 branches
height_increment = height_increment # Increment height for other points

Debugging print to check the value of height_increment

print(“Height Increment:”, height_increment)

Initialize output tree

new_points_tree = DataTreerg.Point3d

Modify the branches

for i in range(points_tree.BranchCount):
branch = points_tree.Branch(i)
path = points_tree.Path(i)
new_branch =

if i < 12:
    start_height = height1
elif 12 <= i < 21:
    start_height = height2
else:
    start_height = 0

for j, point in enumerate(branch):
    new_point = rg.Point3d(point)
    new_point.Z += start_height + j * height_increment
    new_branch.append(new_point)

new_points_tree.AddRange(new_branch, path)

Output

a = new_points_tree

Sorry, I do not think I’ll be able to assist with this… a bit over my head.

Maybe this thread helps?

Hi @baileydw ,

Perhaps I am overcomplicating the matter. Maybe the solution could be to select multiple branches in the data tree: branches 0-11, 12-21, 22-end, and split the tree into 3 separate chunks and remove points from them. Alternatively, managing the count separately (up to 6, 5, or 4 levels) might work. I found this thread:Selecting multiple branches in a datatree. - Grasshopper

What do you think?


240724_ZH_Curve_Rev1.gh (35.6 KB)


240724_ZH_Curve_Rev2.gh (38.3 KB)

Hi @Rajeev2 ,

Thanks a lot! It works!