Morphing with a curve

Hello everybody,

Using the C# srcipting component, I am trying to morph a shape (basically a cube) with a curve as its control structure. I am actually trying to reproduce something that already exists in Rhino: CageEdit (with a line as the control structure) as done on the image below

The control curve (which is initialy a straight line) can stretch/shrink, bend and twist.

I found theMorphControl Class on RhinoCommon API, whose description reads as: “Represents a geometry that is able to control the morphing behaviour of some other geometry.”, which is exactly what I am looking for. However I can’t understand how to use it.

Any help would be greatly appreciated.

Thanks in advance.

ps: the whole project is to morph any arbitrary shape chunk into cubes, using the deformation of a truss. As illustrated (the cubes are still undeformed) below

Hi,

I am looking for something similiar, do have already started? If yes would you mind to share the code?
Regards!

Are you looking to deform or morph into cubes, those are two different things. If you want to morph into boxes Pufferfish has a Twisted Box Curve Component that does what your second screenshot shows.


TBoxCurve.gh (9.6 KB)

If you actually want to deform like your first screenshot grasshopper has a Bend Deform component. There is also regular Bend and also Flow components depending on the control you want your curve to have.

1 Like

Hi Michael,

Thanks for your responses.

No, I am not morphing into cubes. I am deforming a cube, using an inner curve (which acts as a ‘skeleton’): if the curve (which initially is a line) streches/bends/twists, so does the cube.

Below for instance is a combination of bending and twisting, with the same curve.


This has been done manually in Rhino. This was for understanding what I can do in rhino. Now I am trying to script it, by creating a grasshopper C# component, that would take as input the cube to deform and the undeformed and deformed curve and that would deform the cube accordingly.

Can the MorphControl Class handle this? Thanks again, for your help.

@Baris: Thank you for your interest. I haven’t yet managed to write any code to deformed the cube with the curve. May I ask what you are trying to do?

I see, then I think what you are looking for is flow. Here I deform by bending the curve and twisting its control points. If you have R6 then GH has the flow component in the transform tab. If you have R5 the flow component can be found in JACKALOPE (in my screenshot is the jackelope one because I don’t have R6 on this computer).

If you feel you want to remake what already exists then the method is here: https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_Geometry_Morphs_FlowSpaceMorph__ctor.htm

I don’t think you want MorphControl class (although I don’t really know what it does different) as that class seems to deform between two curves, but it just defines the control - I don’t see what deform method then actually uses this controller :smiley: . If you want cage edit like with points then Gh has the spatial deform components. (although I know you want with a curve but I felt it is worth a mention)

Thanks a lot Michael.

What I am trying to do is actually creating a plugin, but before doing the whole thing I am experimenting with the C# script component. So I will try the FlowSpaceMorph class you mentioned. I kind of figured out how to use the MorphControl class, I am still trying things.
Will let you know. Thank you anyway.

ps1: I am on rhino5. The JACKALOPE link you sent, seems broken. I googled it but haven’t found anything.
ps2: I just took a look at pufferfish and it seems awesome!! Thanks.

Sorry fixed it and here is is again: https://www.food4rhino.com/app/jackalope

Basically all the components in there are every spacemorph in rhinocommon, and Gh1 in R6 has all of them included natively. In case you wanted to make a plug-in, better to check someone (or GH1) hasn’t already made it.

Hi,

I ll try to do kind of box morph with blocks.
I managed a planeToplane transformation with blocks, so it works on planar surfaces, now the next step is to change it to be able to apply it on curved surfaces. I hope I can do it this weekend.

I just asked you cuase I thought you maybe have an example code of how to use the morph class.
I had a very quick look, it seems to be something like this:

 private void RunScript(Brep brep, Plane plane, Surface srf, Point3d uv, double scale, double angle, ref object A)
  {


      Rhino.Geometry.Morphs.SplopSpaceMorph map = new Rhino.Geometry.Morphs.SplopSpaceMorph(plane, srf, new Point2d(uv.X, uv.Y), scale, angle);
      map.Morph(brep);
      morphed.Add(brep);

   
  }

Another route could be to just make two components, one that turns block into a gh usable geometry, and another that redefines all the morphed geometry as different instances of the block. Seems more useful because then you can do whatever you want with these blocks using all the transformation components from gh. But I guess Elefront makes this possible already.

yup, thought already about this( the elefron).

I am not trying to reinvent the wheel, I just want to know how to create a wheel.:grinning:

Anyway I am thankful for every hint and in every discussion there is something I can learn.

1 Like

… but how to do this without loosing the material properties of the components of the block?
*scratching my head over this since a while now…