For some reason I cannot get trimmed surfaces with
selection_settings.ObjectTypeFilter = Rhino.DocObjects.ObjectType.Surface
What is its type then? Brep?
issue_unroll.3dm (168.0 KB)
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
tol = sc.doc.ModelAbsoluteTolerance
def get_all_surfs(select=False, include_lights=False, include_grips=False, include_references=False):
"""
modified AllObjects() method to select all selectable objects of type curve
"""
selection_settings = Rhino.DocObjects.ObjectEnumeratorSettings()
selection_settings.IncludeLights = include_lights
selection_settings.IncludeGrips = include_grips
selection_settings.NormalObjects = True
selection_settings.LockedObjects = False
selection_settings.HiddenObjects = False
selection_settings.ReferenceObjects = include_references
#Select all curves
selection_settings.ObjectTypeFilter = Rhino.DocObjects.ObjectType.Surface
# this gets object references
#.Geometry to get the geometry
#.ObjectId to get the uuid
e = sc.doc.Objects.GetObjectList(selection_settings)
return e
def TST():
surfs = get_all_surfs()
list_surfs = [obj.Id for obj in surfs]
print list_surfs
for ID in list_surfs:
print rs.ObjectType(ID)
#rs.UnrollSurface(ID)
if __name__=="__main__":
#print UnrollSurface()
TST()
Yes it’s always brep.
Surfaces can’t store trimming information so when you trim them the result must be a brep
1 Like
Thanks for the reply @lando.schumpich,
Sooo, I cannot use rs.UnrollSurface().
I’ll have to use the unroll method you suggested in one of my previous threads.
The problem is It doesn’t identify BrepFaces in that brep.
Talking about this script:
# created by Lando Schumpich Mar 2019
#
import Rhino
import scriptcontext as sc
def subSurfaceSelectUnroll():
# set up getter
brep_to_unroll = Rhino.Input.Custom.GetObject()
brep_to_unroll.SetCommandPrompt("Sub select a brep face")
brep_to_unroll.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
# get
brep_to_unroll.Get()
# test if success
if brep_to_unroll.CommandResult() != Rhino.Commands.Result.Success:
return brep_to_unroll.CommandResult()
# get geometry (is brepface)
brep_face = brep_to_unroll.Object(0).Geometry()
# get parent
try:
brep_parent = brep_face.Brep
except:
brep_parent = brep_face
# extract face from brep_parent faces list (preserves trims)
try:
brep_trimmed = brep_parent.Faces.ExtractFace(brep_face.FaceIndex)
except:
brep_trimmed = brep_face
# create instance of unroller class, with trimmed face as input
unroller = Rhino.Geometry.Unroller(brep_trimmed)
# marking lines
marking_lines = []
#for i in range(all delimited surfaces):
# marking_lines.append(rs.IntersectBreps(brep_parent,all[i]))
for i in range(len(marking_lines)):
unroller.AddFollowingGeometry(marking_lines[i])
# unroll
arrBrepUnrolled, arrCurveUnrolled, arrPointUnrolled, arrTextDotUnrolled = unroller.PerformUnroll()
# add to doc
for brep in arrBrepUnrolled:
sc.doc.Objects.AddBrep(brep)
if __name__ == "__main__":
subSurfaceSelectUnroll()
I added the "try/except"s
I’m beginning to think it’s my surfaces double curvature that is the problem
This post by @Willem,
solved my problem.
I wish we could use Squish without the need to script the Rhino command though.