[Error] in rs.MovePlane() example

image

If you fix the typo in rs.ViewCplane() to rs.ViewCPlane() there’s another error:

Could anyone explain to me how can I create named CPlanes with python?

Thanks in advance.

“Curiouser and curiouser…”

Start here https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_ConstructionPlane.htm

Once you have created the empty ConstructionPlane, you need to give it a Plane and name.

I have a gh python node somewhere that does this, ping me if you need it. I’ll try to dig it up.

1 Like

Oh my God McNeel, consistency, please?

Once it is a CPlane then it’s a ConstructionPlane. Use the same name in all classes/methods please.

Thanks.

Hi,

do I need to do something like this to use this class?

def myCP(Rhino.DocObjects.ConstructionPlane):
    def __init__(self):
        return Rhino.DocObjects.ConstructionPlane(self)

This MemberwiseClone has always confused me.

This doesn’t do it for you?
https://developer.rhino3d.com/api/RhinoScriptSyntax/#view-AddNamedCPlane

2 Likes

rhinoscriptsyntax was designed to mimic our the RhinoScript library which used the term CPlane. ConstructionPlane is the preferred term in RhinoCommon

Alternative could be if when searching the API somehow when you search for CPlane you also get the ConstructionPlane results.

Is it possible to put Tags or something, when the names of the methods are that different?

About that. Ok so you create a CPlane with a name and origin. How do you define its orientation?

You have these methods, none of which sets the actual plane orientation:

  • AddNamedCPlane
  • NamedCPlane
  • NamedCPlanes
  • RestoreNamedCPlane

Something like below I guess (took me a few minutes to figure it out). Start with a new blank file.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

#define a custom plane
origin=rs.coerce3dpoint([10,10,0])
xvec=rs.coerce3dvector([1,1,0])
yvec=rs.coerce3dvector([0,0,1])
custom_plane=Rhino.Geometry.Plane(origin,xvec,yvec)

#get table of all named construction planes (shouldn't be any in a new blank document)
ncps=sc.doc.NamedConstructionPlanes
#add your custom plane
ncps.Add("My_New_CP",custom_plane)
#print list of named construction planes, new one should now be in it.
print rs.NamedCPlanes()
#restore this plane to the Perspective viewport to see onscreen
rs.RestoreNamedCPlane("My_New_CP","Perspective")

No, you don’t need to inherit from ConstructionPlane. From memory you can use it directly like this (you might have to add it to a table, can’t remember)

import Rhino

my_cp = Rhino.DocObjects.ConstructionPlane()
my_cp.Plane = Rhino.Geometry.Plane.WorldXY
my_cp.Name = "my_cp"

my memory served me poorly…:confused:

I just had fired up the PC and found this works. Ignore my previous comment…

import Rhino
plane = Rhino.Geometry.Plane.WorldXY
result = Rhino.RhinoDoc.ActiveDoc.NamedConstructionPlanes.Add("hello plane", plane)

i found my python gh user objects

attached for your convenience!
they will appear in an Aurecon Experimental Tab, functionality is basic but you’ll get the idea…

AUR_Cplane.Create.ghuser (3.9 KB)
AUR_Cplane.Delete.ghuser (3.5 KB)
AUR_Cplane.Find.ghuser (3.5 KB)

1 Like

Of course you can do this, it does create a new construction plane, but since it is not added to the document, it’s not extremely useful… So you have to add it to the construction plane table as you did above with

Rhino.RhinoDoc.ActiveDoc.NamedConstructionPlanes.Add("my_plane",custom_ plane)

or via the scriptcontext shortcut to the active doc

scriptcontext.doc.NamedConstructionPlanes.Add("my_plane",custom_ plane)
1 Like