GH - Set Plane to View

Hi all, does anyone was able to set the plane of a view withing GH. I tried with a basic definition in Python, it works but it freezes grasshopper once completed. I attached the definition, thanks in advance.

import rhinoscriptsyntax as rs

if x :
sc.doc = rc.RhinoDoc.ActiveDoc
rs.CurrentView
rs.Command("_cplane view")
sc.doc = ghdoc

#Python
import Rhino
if (reset):
    vp = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
    origin = vp.CameraTarget
    xDir = vp.CameraX
    yDir = vp.CameraY
    pl = Rhino.Geometry.Plane(origin, xDir, yDir)
    vp.SetConstructionPlane(pl)
//CS
private void RunScript(bool reset, ref object A)
{
  if (!reset) return;
  var vp = RhinoDocument.Views.ActiveView.ActiveViewport;
  var origin = vp.CameraTarget;
  var xDir = vp.CameraX;
  var yDir = vp.CameraY;
  var pl = new Plane(origin, xDir, yDir);
  vp.SetConstructionPlane(pl);
}

SetConstructPlane.gh (4.7 KB)

3 Likes

Thank you!