Rhino command line in C#

I’m trying to understand how can I use commands directly in c# component.

follow example i’m using command “SetPt” after I imported a geometry, because I want to all my imported geos are set to Z=0, after that the command “CloseCrv” to close them…
i read rhinocommon api examples but didnt get that, can anyone help me to better understand?

string cmdSetPt = “!_SetPt " + “”” + selectedObjs + “-z” + “0” + “”" + " _Enter";
Rhino.RhinoApp.RunScript(cmdSetPt, true);

import geos.3dm (28.4 KB)
import geos.gh (4.2 KB)
draw.dwg (53.7 KB)

Why do that? Why not use some relatively simple RhinoCommon directly?

For more or less the equivalent of using SetPt for ‘flattening’ objects to the world XY plane, it just involves creating the world XY plane - plane=Rhino.Geometry.Plane.WorldXY -, then creating a planar projection transformation xform=Rhino.Geometry.Transform.PlanarProjection(plane) then transforming your curves via something like curve.Transform(plane).

For CloseCrv there is something like Rhino.Geometry.Curve.MakeClosed() - depending on how you plan on closing them, if you want to add a line segment instead of moving the ends, you may need to write a few more lines of code.

1 Like