Soft Move/Transform but in Grasshopper?

Hi guys,

I am trying to edit points on my surface as with command SoftMove or SoftTransform.

I was able to achieve this with the def below but I am not a fan of Graph Mapper as it does not provide precise control. It is also not very intuitive.

For some reason I was not able to make the definition work with multiple surfaces.

So in summary I would like to:
-Replace Graph Mapper with an actual formula/expression/script component
-Make it work for multiple surfaces at the same time.
-Added bonus would be to have individual amplitude and wavelength control for each attraction point.

Def here:
SoftTransform_v01.gh (112.1 KB)


I actually tried using Rhino.Geometry.Surface.CreateSoftEditSurface
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.surface/createsofteditsurface?version=8.x
But C# component asks for Point2D (no idea what that is) while not providing the hint option for a point 2D, very intuitive :thinking:

I can see Point3d there but no Point2d, so machine is asking me the impossible. :man_shrugging:

Hi @ShynnSup,

For the Point2d, you have to create one yourself since this is not a geometry type that Grasshopper knows about: https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.point2d?version=8.x. Evaluating a surface at a set of uv-parameters only needs two parameter values (u and v), so we usually use a Point2d for that (a Point2d is the same as a Point3d except it only has 2 coordinates).

This code seems to work in your C# script:

    var uv = new Rhino.Geometry.Point2d(uvP[0], uvP[1]);
    Surface out_surface = Rhino.Geometry.Surface.CreateSoftEditSurface(srf, uv, vector, ulength, vlength, tolerance, false);
    A = out_surface;

with uvP a Point3d input, and srf a NURBS surface.

Note that you need to use the fixEnds=false parameter in this function, otherwise control points on the boundary of the surface will stay fixed and in your case that fixes all the control points.

You would probably find it easier to use CreateSoftEditCurve, on the bottom edge of your surface only, then rebuild the surface as a loft from top to bottom edge. Otherwise, CreateSoftEditSurface will try to move the control points on the top edge and you will need to set them back to their original positions.

For the rest of the script, I made a very heavy-handed attempt at making the middle version with amplitudes work with multiple surfaces and control of amplitude for each attraction point. Iā€™m building the data trees manually and rewriting paths a couple of times, so there is probably a smarter and more compact way to do that.

Replacing the graph mapper is just a question of writing the equation of a 0-centered Gaussian in an Expression component.

Hope this helps:
DI-165687_PEC_SoftTransform_v01.gh (143.9 KB)

2 Likes

This is awesome @pierrec thank you so much for the thorough reply and for looking at each item I mentioned! :100: