Flow along Curve for Block instances

If I use the regular Rhino Flow along curve on Block instances - they work fine.
The same is not true for Grasshopper.
While writing a similar code, we couldn’t get the block instances into our geometry base list as blocks. They were getting converted to polysurfaces. This causes us to loose info attached to it.

If the blocks can flow correctly in Rhino, how can I achieve it with RhinoCommon / C #?
@dale @stevebaer @Kartik_Gavande

1 Like

Hi @maya_puundale,

Rhino’s Flow command performs a deformation, or space morphing, operation on selected objects. This operation is much different than a transformation, which applies a 4x4 transformation matrix to the geometry.

A block instance object contains a reference to the instance definition and a 4x4 transformation matrix that defines the location, rotation, scale, etc., to the instance definition geometry when drawing. Thus, block instances support transformation. But it is not possible to perform a space morph operation on a block instance.

What the Flow command, and other space morph commands, do is define some plane through the block instance object, “morph” the plane, create a rotation transformation, and then transform the block instance object. This is also what the “Rigid” command line option does.

Some pseudo-code that might help:

import Rhino
import scriptcontext as sc

def __MorphPlane(in_plane, morph):
    rc, out_plane = morph.Morph(in_plane)
    if rc
        out_plane.CreateFromFrame(out_plane.Origin, out_plane.XAxis, out_plane.YAxis);
    return rc, out_plane

# TODO: Get some block instance object here
block_instance = <some block instance>

# TODO: define flow space morph here
morph = Rhino.Geometry.Morphs.FlowSpaceMorph()

# TODO: Get some block instance object plane here
plane0 = GetBlockInstancePlane(block_instance)

# Morph the plane
rc, plane1 = __MorphPlane(plane0, morph)
if rc:
    xform = Rhino.Geometry.Transform.PlaneToPlane(plane0, plane1)
    sc.doc.Objects.Transform(block_instance, xform, False)

Does this help?

– Dale

2 Likes

Thanks @dale , this will be of help
Although the morph for the block instances will still be sort of an approximation right because even when we did it in rhino ,after morphing the position of blocks wasn’t exact.

RH-84615 is fixed in Rhino 8 Service Release 14