Forgot password?

Create an account!

RVB

« back

Extract Viewport Extents

Description RhinoScript Tool

RhinoScript Tool by drape

a tool for getting the current viewpoint boundary
useful with Make2D and compositing

Version

Version 1.1 (Feb 26, 2009)


Changes since previous version:

made it cleaner. used addPolyline instead of addLine...no Rhino.command...

« older versions

Requirements

Other requirements: This script requires "ViewNearCorners" to work. Not sure what SR that requires.

Code

You need to be logged in to view the source code.

Download

You need to be logged in to download the script.

Comments
  • +++ Feb 26, 2009 22.21: Extract Viewport Extents version 1.1 published +++

  • 5. drape (Feb 26, 2009 22.07):

    Ok, I need to wait a little before posting and test a little more :) I answered my own question. I only needed to add the last element of the array.

    Dim arrRect
    Dim arrObjects, strObject, strLayer
    Dim viewportLayerName

    arrRect = Rhino.ViewNearCorners
    viewportLayerName = "Viewport Extents"

    If IsArray(arrRect) Then

    ReDim Preserve arrRect(4)
    arrRect(4) = arrRect(0)

    Rhino.EnableRedraw(False)

    Rhino.AddLayer (viewportLayerName)
    Rhino.CurrentLayer(viewportLayerName)
    Rhino.AddPolyline (arrRect)

    Rhino.EnableRedraw(True)

    End If

  • 4. drape (Feb 26, 2009 21.59):

    Ok, I need to wait a little before posting and test a little more :) I answered my own question. I only needed to add the last element of the array.

    Dim arrRect
    Dim arrObjects, strObject, strLayer
    Dim viewportLayerName

    arrRect = Rhino.ViewNearCorners
    viewportLayerName = "Viewport Extents"

    If IsArray(arrRect) Then

    ReDim Preserve arrRect(4)
    arrRect(4) = arrRect(0)

    Rhino.EnableRedraw(False)

    Rhino.AddLayer (viewportLayerName)
    Rhino.CurrentLayer(viewportLayerName)
    Rhino.AddPolyline (arrRect)

    Rhino.EnableRedraw(True)

    End If

  • 3. drape (Feb 26, 2009 21.55):

    Thanks for your comments Habbo. I figured it out and my solution is below. However, before I upload a new version, i'm wondering if you have any tips to make the rebuild of the array tighter?



    Dim arrRect
    Dim arrObjects, strObject, strLayer
    Dim viewportLayerName

    arrRect = Rhino.ViewNearCorners
    viewportLayerName = "Viewport Extents"

    If IsArray(arrRect) Then

    ReDim Preserve arrRect(4)
    arrRect(0) = arrRect(0)
    arrRect(1) = arrRect(1)
    arrRect(2) = arrRect(2)
    arrRect(3) = arrRect(3)
    arrRect(4) = arrRect(0)

    Rhino.EnableRedraw(False)

    Rhino.AddLayer (viewportLayerName)
    Rhino.CurrentLayer(viewportLayerName)
    Rhino.AddPolyline (arrRect)

    Rhino.EnableRedraw(True)

    End If

  • 2. Hanno (Feb 24, 2009 10.55):

    Hi,

    to make a closed polyline, you simply need to repeat the first point as last point (so a rectangle is a polyline with 5 points).
    And the methods you are looking for are JoinCurves and UnselectAllObjects, but it looks like you need neither of them if you draw a polyline :-)

    Hope that helps!

    Hanno

  • 1. drape (Feb 23, 2009 20.48):

    Hello. This is my first script on rhinoscript.org. I'm pretty new to scripting. This script could use some improvements. But it does seem to work well for me.
    Two improvements I would like help with:
    - How to make a polyline or rectangle directly from ViewNearCorners instead of 4 lines. I was only able to make 3 out of 4 sides of a rectangle with polyline so i switched to line.
    - how to avoid Rhino.command for Join and selNone.

    Thanks

  • +++ Feb 23, 2009 20.45: Extract Viewport Extents version 1 published +++