Slider in viewport

Hello @dale
I used your example to create a slider in the viewport and it work fine but when i switch to one viewport the slider have no effect.
And how we can show the slider in non parallel views only?

Maybe something wrong in Dollyzoom code or Mouseevent?

bool isPerspective() // this have no effect when i used it as condidtion for e.Display
  bool viewtype = false;
  foreach (RhinoView v in RhinoDoc.ActiveDoc.Views.GetViewList(true, false))
    if (!v.ActiveViewport.IsParallelProjection) 
    viewtype = true;
  return viewtype;

void DollyZoom(float newLenght)
  RhinoView activeview = RhinoDoc.ActiveDoc?.Views?.ActiveView;
  RhinoViewport vp = activeview.ActiveViewport;
  if (!vp.IsParallelProjection)
    var oldlength = vp.Camera35mmLensLength;
    if (newLenght.ToString() != null)
      var k = newLenght / oldlength;
      var loc1 = vp.CameraLocation;
      var tar = vp.CameraTarget;
      var loc2 = k * loc1 + tar * (1 - k);
      vp.SetCameraLocations(tar, loc2);
      vp.Camera35mmLensLength = newLenght;


public class MouseEvent : MouseCallback
    public static float position;
    protected override void OnMouseMove(MouseCallbackEventArgs e)
      if (e.MouseButton == MouseButton.Left)
        position = e.ViewportPoint.Y;
        //e.View.Redraw(); this didn't work!


This work to show slider in non parallel view

if (!e.Viewport.IsParallelProjection){}

The problem of large viewport related to the scale but i don’t find a solution.
I use a method mathematically correct but something is missing, i think the scale

I calculate the distance in percentage, the text show exact value at exact position theoretically, but It is not in viewport


I fixed the length of the slider ,this work better but still the problem with large viewport don’t respond to the change of value.

Problem fixed .
Is there an event when the view maximized?

No, there is not. But the viewport should be redrawn, which will trigger your conduit.

– Dale

1 Like