How use Python make _ProjectToCPlane command?


#1

Hello,

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

Thank you.


(Willem Derks) #2

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


#3

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()


(Willem Derks) #4

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


#5

Thanks for your help. It works well.


#6

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.


(Willem Derks) #7

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:


#8

Thank you. I will learn it.