# Transform from curves from world XYZ to a surface space UVN

Hi,

I’m looking for a way to transform curves from WorldXYZ to a Surface’s UVN
i.e. script the ApplyCrv command

I’m scripting in Python and have not found anything yet in RhinoCommon. I try and dig deeper while waiting for someone to chime in here.

I have found a solution that seems to be what ApplyCrv does:

``````    # bbox is boundingbox from all iso_curves (these need to be morphed)
Uplane_interval = Rhino.Geometry.Interval(bbox.Min[0], bbox.Max[0])
Vplane_interval = Rhino.Geometry.Interval(bbox.Min[1], bbox.Max[1])
# create a planar surface on XY plane around geometry to be morphed
from_surface = Rhino.Geometry.PlaneSurface(Rhino.Geometry.Plane.WorldXY, Uplane_interval, Vplane_interval)

# create SporphSpaceMorph instance (who's been drinking while making up these names?)
# to_surface is NurbsSurface to 'Apply the curves to'
Morph = Rhino.Geometry.Morphs.SporphSpaceMorph(from_surface,to_surface)

# Morph the geometry one by one
for crv in iso_curves:
Morph.Morph(crv)
``````

Thanks
-Willem

If your reference surface has the same domain as the target surface, it should be pretty straightforward to evaluate the target srf based on the uv coordinates of the reference. For this I would divide the curves to your specified resolution, get the closet point on the reference surface, and evaluate the target surface at that uv point. Again, both the reference surface and the target surface should have the same domain. You can set that with setDomain. If the original curves are not planar, you could offset the resulting evaluated point based on the distance from the reference surface at the uv parameter of the target surface.

Hi Willem,

ApplyCrv is actually a transformation operation. When I get a chance (next week) I’ll type up an example for you.

– Dale

and @dale please note that the online sdk doc is completely missing most of the morph classes - fortunately it does show up in the python editor left column tree view.

–Mitch

Thanks for the replies. I believe I have it working now
To give some insight of what I’m doing:
For the production of twisted strips in steel we wanted some indication on the unrolled surface of the curvature. In particular the minimum radius iso-curves.

What I do now is sample the surface minimum radius in a dense grid.
Next I create a surface through the points with coordinats [u,v,minimum-radius]
This gives me a world aligned ‘topography’ of the minimum-radius in the respective XY / UV coordinate
After projecting the iso-curves to the XY-plane I use the SporphSpaceMorph to apply them to the original surface.

I have already found that I need to take another look at SporphSpaceMorph and the input surfaces.

Isocurves over a CurvatureAnalysis

Thanks
-Willem

Why not use marching squares algorithm on your dense grid, it gives you the iso contour lines directly.