Automatic flowalongsurface

How can I do to run flowalongsurface automatically.
The base and target surfaces are known.

I need in Python

@cristiano.pasini here a quick try at translation

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc


def flowAlongSrf():
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select object to sporph", False, Rhino.DocObjects.ObjectType.AnyObject)
    

    go0 = Rhino.Input.Custom.GetObject()
    go0.SetCommandPrompt("Source surface")
    go0.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
    go0.SubObjectSelect = False
    go0.EnablePreSelect(False, True)
    go0.DeselectAllBeforePostSelect = False
    go0.Get()
    if (go0.CommandResult() != Rhino.Commands.Result.Success):
        return go0.CommandResult()

    srf0_ref = go0.Object(0)

    go1 = Rhino.Input.Custom.GetObject()
    go1.SetCommandPrompt("Targe surface");
    go1.GeometryFilter = Rhino.DocObjects.ObjectType.Surface;
    go1.SubObjectSelect = False
    go1.EnablePreSelect(False, True)
    go1.DeselectAllBeforePostSelect = False
    go1.Get()
    if (go1.CommandResult() != Rhino.Commands.Result.Success):
        return go1.CommandResult()

    srf1_ref = go1.Object(0)

    morph = Rhino.Geometry.Morphs.SporphSpaceMorph(srf0_ref.Surface(), srf1_ref.Surface());

    geom = objref.Geometry().Duplicate()
    if (morph.Morph(geom)):
        sc.doc.Objects.Add(geom)
        sc.doc.Views.Redraw()

    return Rhino.Commands.Result.Success
flowAlongSrf()

@Gijs runs Ok… Perfect… but how do i pass the Id object to this example of yours.
My surfaces were created by rhinoscript.

@cristiano.pasini that’s even more simple. In that case you don’t need the whole Rhino Getobject stuff. Just make srf0_ref equal to your source and srf1_ref equal to your target.

@Gijs

Rhino.Geometry.Morphs.SporphSpaceMorph needs <Rhino.Geometry.BrepFace>
How to extract Geometry Brep Face from Id. How to convert?

@Gijs

:sweat_smile:
I use rs.coercesurface

Thanks!!!

Maybe this helps? Otherwise post your code

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc


def flowAlongSrf():
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select object to sporph", False, Rhino.DocObjects.ObjectType.AnyObject)
    
    srf1 = rs.GetObject("select source surface")
    srf2 = rs.GetObject("select target surface")
    srf1 = rs.coercesurface(srf1)
    srf2 = rs.coercesurface(srf2)
    morph = Rhino.Geometry.Morphs.SporphSpaceMorph(srf1,srf2)

    geom = objref.Geometry().Duplicate()
    if (morph.Morph(geom)):
        sc.doc.Objects.Add(geom)
        sc.doc.Views.Redraw()

    return Rhino.Commands.Result.Success
flowAlongSrf()

@Gijs It worked. thank you

Can I morph mesh grips object?

Hi. Sorry for bumping an old thread but I’m wondering if I want to access the flowed object what would be its ID? I tried selecting it by using ‘LastCreatedObjects’ for example but it does not seem to work.

If I would want to name the object when flowing it, how would I do it?

Thanks.

You need to work with Rhinocommon.
First convert the object:
rs.coercesurface(ID)
Then work with Rhinocommon…
Rhino.Geometry.Morphs.SporphSpaceMorph is Rhinocommon