Hello everyone,
I’ve been looking for a long time, but I can’t find the solution.
I really hope you can help me.
I want to delete some subsurfaces from a polysurface. But I want to be able to make a selection of several subsurfaces at the same time.
From what I understand, Rhinocommon is the best/only tool for the job.
But rhinocommon’s behavior means that I can’t delete the selected subsurfaces without deleting the whole polysurface.
I thought I’d try extracting the sub-surfaces in order to remove them from the polysurface.
But same thing, the surfaces are extracted, but the originals always remain.
Whereas when I use rs.GetObject to select a single subsurface, it is extracted and the original is removed.
So rs.GetObject allows you to select a subsurface, but only one at a time.
And I can’t delete the originals subsurfaces, with Rhinocommon.
Thanks for your help and explanations, I really need them.
import rhinoscriptsyntax as rs
import Rhino
def get_brep_faces():
sub_surfaces = []
# Create a GetObject object to prompt the user to select surfaces
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt("Select surfaces")
go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
go.SubObjectSelect = True
go.GetMultiple(1, 0)
# Check if the user selection was successful
if go.CommandResult() != Rhino.Commands.Result.Success:
return
# Iterate through the selected objects
for objref in go.Objects():
# Get the face of the object reference
face = objref.Face()
# Convert the face to a Brep
sub_srf = face.ToBrep()
# Append the Brep to the list of sub-surfaces
sub_surfaces.append(sub_srf)
# Print information about the selected object
print(objref.ObjectId)
print(objref.GeometryComponentIndex.ComponentIndexType)
print(objref.GeometryComponentIndex.Index)
# Check if any sub-surfaces were selected
if sub_surfaces is None:
print("No sub-surfaces selected.")
else:
print("Sub-surfaces have been selected successfully.")
return sub_surfaces
# Call the get_brep_face function to get the sub-surfaces
subsurfaces = get_brep_faces()
# If there are sub-surfaces, extract them from their parent surfaces
if subsurfaces:
for obj in subsurfaces:
rs.ExtractSurface(obj, 0, False)
4 posts - 3 participants