Squish in GH Python uses wrong surface despite correct input after split

squish using python.gh (32.5 KB)
Hi all,

I’m working on an automated flattening process using _Squish inside a Grasshopper Python component in Rhino 7.


Here’s what I’m trying to do:

  1. Split a surface in Grasshopper (e.g., using brep).
  2. Send the trimmed surfaces into a GH Python component.
  3. Bake the surface.
  4. Use _Squish on the baked geometry and retrieve the result back into GH.

:wrench: Problem

Even though the split works correctly and I pass the trimmed surfaces to Python, the _Squish command always processes the original (pre-split) surface — not the trimmed result.

What I tried

  • I confirmed that the srfs input into Python shows only the trimmed surfaces.
  • I bake the surface, then try to select and squish it using its Id.
  • I tried using both:
    • Grouping baked geometry and selecting it
    • Baking with attributes (Name) and using _SelName
  • But Squish seems to still act on the wrong geometry.

How can I ensure that the Squish command only acts on the baked version of the currently selected trimmed surface?

Is there a more reliable way to bake, fetch, and squish the geometry—perhaps using Squisher() directly in RhinoCommon?

Any help or sample patterns would be much appreciated :folded_hands:

Thanks!

Maybe this is helpfull?

Trimmed surfaces are “Breps” and not “Surfaces” in Rhino and Grasshopper.
Since Grasshopper itself is quite liberal with input, performing implicit type conversions for you, you likely feed in a Brep (=Trimmed surface) to a Surface (=Raw surface) input.

public Brep SquishSurface(
  SquishParameters sp,
  Surface surface,
  IEnumerable<GeometryBase> marks,
  List<GeometryBase> squished_marks_out
)

The Squisher class only supports Surface (=untrimmed) input.

You can however try to reapply the trim on your squished surface.
See Copy Trim component

I think this is what you want:

DI-207248_squish using python_PEC.gh (21.0 KB)

The trick is to make sure you are setting your input type to Brep in GH, calling the Squisher.SquishSurface() method like this:

squisher = rg.Squisher()
marks = list(edge_crvs) + dots
squished_marks = [_ for _ in marks]
squished_marks = System.Collections.Generic.List[rg.GeometryBase]()
squished_brep = squisher.SquishSurface(
    rg.SquishParameters(),
    brep.Faces[0],
    marks,
    squished_marks
)

Note that this method can accept Rhino.Geometry.Surface as its second parameter, which is a generic type for trimmed and untrimmed surfaces, including a single BrepFace.

I didn’t look very carefully at the rest of the script after that.

2 Likes

It only supports Rhino.Geometry.Surface, which is (almost?) the same as GH’s Surface parameter type, but different to GH’s Surface input type in Python script components. (Yes, I know, confusing)

Rhino.Geometry.Surface is a parent class for BrepFace, so it can support trimmed surfaces. The full inheritance chain: Rhino.Runtime.CommonObjectRhino.Geometry.GeometryBaseRhino.Geometry.SurfaceRhino.Geometry.SurfaceProxyBrepFace

For reasons that I’ve forgotten, selecting Surface as a type hint in a GH Python Script component will convert almost everything to a Rhino.Geometry.NurbsSurface, which does not support trims (and is a subclass of Rhino.Geometry.Surface).

1 Like

Thank you so much!