Separate polysurface

Hi, could you help me to separate polysurface please? I’ve found only node for solids separation.
Thank you

Hi the Polysurface.Surfaces node returns you what list structure
edit:
taking the returned surfaces
and extruding them by a small value
(this will give you x solids)
you unify them
the centroid of this object is outside the polysurface
you have a point to create a boundingbox and test the surfaces inside it
a little convoluted I grant you that
edit 2:
I did a little digging:
If the gap between the 2 polysurfaces is large enough to be able to create a section of the boundingbox it could work
(the cut remains amateurism in this case since I am therefore watching cheating)


Wait for a more enlightened solution than mine
Have a good evening
Sincerely
christian.stan

1 Like

:thinking:

Might be better to analyze the faces directly instead of solids or hoping for bounding boxes… might also be a means via mesh toolkit now that I think about it.

Did you try Geometry.Split?

Hello, look at the node side

Sincerely
christian.stan

I couldn’t think up a clean solution which doesn’t use C#, Python, or a custom design script definition.

The first on that list isn’t something readily distributed, and the last will usually lead to more questions than answers. So here’s some Python for you (you’ll have to build the means of iterating over a list of PolySurfaces (though you might just convert them to a single PolySurface first):

import sys,clr #import the sys and CLR modules
clr.AddReference('ProtoGeometry') #add the Dynamo geometry library to the CLR
from Autodesk.DesignScript.Geometry import * #import all of the Dynamo geometry library

polySurface = IN[0] #the polysurface to separate

faces = [i for i in polySurface.Faces] #pull the topology of the PolySurface

polysurfaces = [] #the resulting list of PolySurfaces

while faces: #while there are faces in the list
    toGroup = [faces.pop(0)] #pull the first face out and put it in the toGroup list
    grouped = [] #a list to hold the groups of faces
    
    while toGroup: #whiel there are items to group
        face = toGroup.pop(0) #pull the face out of the to group list
        grouped.append(face) #append the face to the grouped list
        edges = face.Edges #get the edges of the face
        adjFaces = [i for edge in edges for i in edge.AdjacentFaces] #get the adjacent faces for the edges
        
        for f in adjFaces: #for every face in the adjacent faces list
            if (f not in grouped) and (f not in toGroup): #if the face is not in the grouped list or in the toGroup list
                faces.remove(f) #remove the face from the faces list
                toGroup.append(f) #append the face to the toGroup list
    surfs = [f.SurfaceGeometry() for f in grouped] #convert the faces to surfaces
    polysurfaces.append(PolySurface.ByJoinedSurfaces(surfs)) #generate a polysurface and append to the list of polysurfaces

OUT = polysurfaces #return the list of PolySurfaces to the Dynamo environment
3 Likes