Can one define a Cplane in a Python script?

…All in the title.
From 3points for example ?
Jean P.

Hi Jean,

An easy way is to use the ViewCPlane method from rhinoscriptsyntax:

import rhinoscriptsyntax as rs
origin = rs.GetPoint("CPlane origin")
if origin:
    plane = rs.ViewCPlane()
    plane = rs.MovePlane(plane,origin)
    rs.ViewCPlane(None, plane)

Use the PlaneFromPoints method to create a plane from 3 points. Then pass this plane to ViewCPlane.

Check the Rhino.Python help file for more details.

1 Like

Thanks, Dale.
Your solution is for the current view.
I wonder how I can set the specific view.
I tried like:
plane = rs.ViewCPlane(‘right’)
to select the right view, but it dosen’t work.
Could you please have some clues?
Thank you again.

To set a CPlane, you need two arguments, the view and the plane.

plane = rs.ViewCPlane('right')

will only return what plane is active in the Right view - if it exists. It does not set anything.

Note also that it actually has to be spelled 'Right' and not 'right' - Python is case sensitive and so ‘right’ is not recognized as a standard view.

If you want to set a CPlane in a known view, you need to supply the plane you want to set as well as the name of the view you want to set it to. For example, to set the ‘Right’ view CPlane in the Perspective viewport:

import rhinoscriptsyntax as rs

right_view_plane=rs.ViewCPlane('Right') #returns the plane currently set in 'Right'
rs.ViewCPlane('Perspective',right_view_plane) #sets that plane in 'Perspective'

Otherwise, you can define the plane to be set in the view with any method that defines planes - for example, as Dale suggested, set a plane using 3 points:

import rhinoscriptsyntax as rs

p1=rs.coerce3dpoint([0,0,0]) #origin of cplane
p2=rs.coerce3dpoint([1,1,1]) #point on x-axis of cplane
p3=rs.coerce3dpoint([-1,1,1]) #point in direction of y-axis of cplane

plane=rs.PlaneFromPoints(p1,p2,p3) #define the plane
rs.ViewCPlane('Perspective',plane) #set the plane in 'Perspective' view

The above sets a 45° oblique plane in the Perspective viewport.


1 Like

Thank you so much @Helvetosaur, for your detailed explanation!!
I got what I want.
Sorry to reply late: I didn’t expect such a prompt reply in weekend.
Thank you again!