NamedCplane to NamedView

Hi anyone

I’d like to know how to save NamedView that is a parallel projection of NamedCplane in Rhinocommon(Python).
I think it would be possible if Plan command could be implemented in Rhinocommon.
Please tell me how to write it.



Kind regards,
Reomaru

1 Like

It would work something like this but with a proper camera setup. I’m not proficient at scripting, hopefully this can get you started.

import rhinoscriptsyntax as rs
import scriptcontext as sc


names = rs.NamedCPlanes()
for name in names:
    plane = rs.NamedCPlane(name)
    vect = rs.VectorAdd((0,0,100),plane.ZAxis)
    vp = sc.doc.Views.ActiveView.ActiveViewport
    vp.SetCameraLocation(plane.Origin, False)
    vp.SetCameraDirection(vect, True)
    rs.AddNamedView(name)

2 Likes

Rhino.DocObjects.Tables.ViewTable viewTable = RhinoDoc.ActiveDoc.Views;
Print(" ");
foreach(Rhino.Display.RhinoView rview in viewTable) Print(“View: {0}, displayMode: {1}”, rview.ActiveViewport.Name, rview.ActiveViewport.DisplayMode.EnglishName);

Rhino.DocObjects.Tables.NamedConstructionPlaneTable nctable = RhinoDoc.ActiveDoc.NamedConstructionPlanes;
Print("Named cPlanes: {0}", nctable.Count);
if(!nctable.Any())return;

if(index >= nctable.Count)index = nctable.Count - 1;
ConstructionPlane cPlane = nctable[index];
Point3d camLoc = cPlane.Plane.Origin;
Vector3d camUp = cPlane.Plane.ZAxis;

Rhino.Display.RhinoView view = doc.Views.ActiveView;
Rhino.Display.RhinoViewport vp = view.ActiveViewport;
string name = view.ActiveViewport.Name;

vp.PushViewProjection();
vp.CameraUp = -camUp;
vp.SetCameraLocation(camLoc + camUp * pFactor, false);
vp.SetCameraDirection(-camUp, true);
vp.Name = name;

doc.NamedViews.Add(name, vp.Id);
view.Redraw();
3 Likes

Thank you for giving me good advice :laughing:

Thank you so much!!
I will try your script :laughing: