Precise Panning

Hi,

Just exploring if panning is scriptable in Rhino 5.0, as there are no commands for precise panning. It would be very useful for arranging drawings in detail views for layout.

For example I would like to pan within a detail view 400 units in the x direction.

Any ideas how this would be possible?

Something like this:?

 Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
            Dim x As Integer
            Dim y As Integer
            Dim z As Integer
            RhinoGet.GetInteger("Move X (As integer)", True, x)
            RhinoGet.GetInteger("Move Y (As integer)", True, y)
            RhinoGet.GetInteger("Move Z (As integer)", True, z)

            Dim view As Display.RhinoViewport = doc.Views.ActiveView.ActiveViewport
            Dim target As Point3d = view.CameraTarget
            target.X = target.X + x
            target.Y = target.Y + y
            target.Z = target.Z + z
            view.SetCameraTarget(target, True)

            doc.Views.ActiveView.Redraw()
            Return Result.Success
        End Function

Right mouseclick on the rhp file and unlock.
Then drag and drop in rhino and use the command Pan2

or script it like: Pan2 Enter 10 Enter
it pans Y + 10

pan2.rhp (12 KB)

Great! It works well on my end. Thank you for writing that.

Would it be possible to integrate a pan from… to… element to that command? Does this psudeo code make sense?

get “pan from” co-ordinates = F
get “pan to” co-ordinates = T
T-F = A
camera target co-ordinates + A = new target co-ordinates

Pan2.rhp (13.5 KB)

Commands:
Pan2 - With X, Y, Z settings
PanFromTo - will set 2 points for distance and will save the “jump”
PanRedo - Redo the same “Jump”

PanFromTo

   Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
            Dim PtFrom As Point3d, PtTo As Point3d
            RhinoGet.GetPoint("From (Pick Point)", True, PtFrom)
            RhinoGet.GetPoint("To (Pick Point)", True, PtTo)

            Dim PtNew As Point3d = PtTo - PtFrom

            Dim view As Display.RhinoViewport = doc.Views.ActiveView.ActiveViewport
            Dim target As Point3d = view.CameraTarget
            view.SetCameraTarget(PtNew + target, True)

            My.Settings.X = PtNew.X
            My.Settings.Y = PtNew.Y
            My.Settings.Z = PtNew.Z
            My.Settings.Save()

            doc.Views.ActiveView.Redraw()


            Return Result.Success

        End Function

PanRedo

  Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
            Dim view As Display.RhinoViewport = doc.Views.ActiveView.ActiveViewport
            Dim target As Point3d = view.CameraTarget

            Dim pt3D As New Geometry.Point3d(My.Settings.X, My.Settings.Y, My.Settings.Z)
            view.SetCameraTarget(pt3D + target, True)

            doc.Views.ActiveView.Redraw()
            Return Result.Success

        End Function

Thank you for publishing the code again, very useful for me learning.

One minor thing. When using the PanFromTo command, I feel it does the reverse of what is requested, ie. it pans from the second point to the first point? Pherhaps I’m misunderstanding the steps, but it feels counter intuitive.

Anyway thanks again, very useful!

B

Just tested it and it pans from the first point to the second point.

No problem.

Jordy