Orienting planar curves to current view?

hi all ,

I extract a lot of curves form 3D models for CNC milling. A lot of the times I get these curves from the left/right/bottom viewports. But then I have to nest these curves onto sheets of material, so I need them all in the same viewport oriented correctly.

Is there a function, shortcut or alias for that following situation?

You could make a little script for it, that gets the planes of the planar curves and then does a plane/plane transform to your top viewport. Does the orientation matter? The plane of the curve can be in two directions so the curve might end Z up or Z down

The RemapCPlane command might help here, combined perhaps with ProjectToCPlane to flatten them on the top CPlane/view afterwards.

here’s an example (no extensive error checking):

import Rhino
import rhinoscriptsyntax as rs


def orient_curves():
    """
    example to orient planar curves to world XY plane
    """
    curves = rs.GetObjects("select curves to orient", 4)
    if not curves:
        return
    new_curves=[]
    for curve in curves:
        
        plane = rs.CurvePlane(curve)
        if plane:
            transform = Rhino.Geometry.Transform.ChangeBasis( Rhino.Geometry.Plane.WorldXY, plane)
            rs.TransformObject(curve, transform)
            new_curves.append(curve)
    for curve in new_curves:
        #align curves left
        bb = rs.BoundingBox(curve)
        trans = -bb[0]
        rs.MoveObject(curve, trans)
    
    while len(new_curves)>0:
        #spread the curves
        bb = rs.BoundingBox(new_curves[0])
        trans = bb[1]-bb[0] +Rhino.Geometry.Vector3d(5,0,0)
        new_curves.pop(0)
        
        rs.MoveObjects(new_curves, trans)
        
orient_curves()