Split Element

Hi guys,

I want to split elements by points. For instance I’ll do a brep curve intersection, find intersection points and use those points to split columns. I see there is a method in API and tried to create my own node in Python but failed miserably. maybe @eirannejad or @japhy can create a quick node and help me :blush:


Curves represents a Column and points represent the split locations.

I can take stab at this weekend, few other issues in the queue to get through first. Getting hung up on the recursion aspect? Were you able split just one via api?

No I wasnt able to split just one.

Ok, so I have done it for a single element. @japhy can I ask for a resource that explains how to use Grasshopper trees in Python? I always struggle in that part.

Beat me to it :slight_smile:

Split Column.gh (6.9 KB)

1 Like

Ask an you shall receive.

datatree_examples.gh (11.7 KB)
treehelpers_simplify_with_base_and_retrievebase.gh (10.4 KB)

1 Like

The recursion part is tricky, you have multiple points on a single column. The first one splits then you have a new element ID and essentially have to start over by testing if the point is inside the brep, then split that column.

you really want to do that all in grasshopper and then send to the python component 1 Element, 1 normalized curve parameter.

Hmm, I think thats why I dont get the result I create in Rhino. Looks like simply deleting and recreating elements is a lot faster. But I’ll try to do it anyway.

How did you go with this @mucahitbgoker & @Japhy ?

Keen to use a RIR components to split Revit Elements -

image

Keen to split Structural Framing elements Fixed to a Reference Plane.

Cause if we recreate the beams, you will lose the connection to the Reference plane that it was attached to. Also, can’t create structural framing to a reference plane.

1 Like

Hey @christopher.pires ,

As described by @Japhy, recursion for split element is tricky cuz of API limitations on Revit side. I ended up recreating elements from scratch.

1 Like

Hi Japhy I tried to copy paste the content of the scripts into Python 3 editors and I get an error:

new file in post below: Split Element - #18 by martinsiegrist

@martinsiegrist import System.Array as array is invalid in Python 3

System.Array is a type not a package. so change that line to from System import Array as array

IronPython allowed this. I’m not sure if this was valid in python 2

Sorry to bother you again.

Here’s the next error:

import Rhino

# for accesssing GH classes
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
from System import Array as array

layerTree = DataTree[object]()  # make a DataTree
for i in range(len(layernames)):
    objs = Rhino.RhinoDoc.ActiveDoc.Objects.FindByLayer(layernames[i])

    if objs:
        geoms = [obj.Geometry for obj in objs]
        path = GH_Path(array[int]([0, 0, i]))
        layerTree.AddRange(geoms, path)

a = layerTree

Oh great catch. I’ll log this to get fixed but for now use DataTree[System.Object]() instead

RH-77500 CPython fails on greating generic types with python types e.g. DataTree[object]

1 Like

Thanks Ehsan, this example works again now.

datatree_examples_python.gh (25.0 KB)

anyway this can work for splitting Wall Elements?

Hi Abhiram,

That particular method says “Splitting is permitted for architectural and structural columns, beams and braces. Beams and braces that are not a line or an arc is not permitted”

Splitting a wall is a feature request for the Revit API

1 Like

I applied a fix in python 3 for Rhino 8.5 that allows using pythons object as a generic argument so a script like this does not throw error and we don’t have to use DataTree[System.Object]

#! python 3
from Grasshopper import DataTree

dt = DataTree[object]

print(dt)