How use Python make _ProjectToCPlane command?

Hello,

I have not fine _ProjectToCPlane command in Python, How can I do for this?

Thank you.

Hi Alen,

short answer:
use
matrix = rhinoscriptsyntax.XformPlanarProjection (plane)
to create a planar projection ( and input current cplane as plane)
Next transform your geometry with
rhinoscriptsyntax.TransformObjects (object_ids, matrix, copy=False)

Does this help?

-Willem

1 Like

Hi Willem,

I write for this code,but it shows Message: global name ‘rhinoscriptsyntax’ is not defined. How can I do?

import rhinoscriptsyntax as rs

def ProjectToCPlane():
msg = "select objects to Project"
crvs = rs.GetObjects(message=msg, filter=4, preselect=True, select=True)
if not crvs: return

matrix = rhinoscriptsyntax.XformPlanarProjection (plane)

rs.EnableRedraw(False)

Trobj = rhinoscriptsyntax.TransformObjects (object_ids, matrix, copy=False)

ProjectToCPlane()

Hi Alen,

I cannot test the code right now but from the top of my head something like this.
Note that rhinoscriptsyntax was the full module name, it’s common use to import it as rs like you already did.

import rhinoscriptsyntax as rs

def ProjectToCPlane():
   msg = "select objects to Project"
   crvs = rs.GetObjects(message=msg, filter=4, preselect=True, select=True)
   if not crvs: return


   plane = rs.ViewCPlane()
   matrix = rs.XformPlanarProjection (plane)

   rs.EnableRedraw(False)

   Trobj = rs.TransformObjects (crvs, matrix, copy=False)

ProjectToCPlane()

Does this help?

-Willem

Thanks for your help. It works well.

Hi,

If I want to copy object command by using Python code, how to write it? I know rhino command is _copy to do this.

Hi Alen,

That would be

CopyObject(object_id, translation=None)

Check out the online documentation on all rhinopython methods:
http://developer.rhino3d.com/api/RhinoScriptSyntax/win/

-Willem

In addition if you use the python editor (command _EditPythonScript) you get an overview of the rhinoscriptsyntax on the left pane as well:

1 Like

Thank you. I will learn it.