Grasshopper

algorithmic modeling for Rhino

For an active Rhino view, I want to create a rectangle that is orthogonal to the camera and is the exact size of the viewport.  Essentially, I want the near viewing frustum, but as a 3d geometry, not a distance.  (Actually, I really want something just beyond the near frustum, since I want objects in the plane of this rectangle to be visible to the camera.)

Is this possible in VB or using GH components?

-Jon

Views: 2472

Replies to This Discussion

Hi Jon,

yes, this is possible. Are you using RhinoCommon or the RhinoDotNET SDK?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Private Sub RunScript(ByVal vp As String, ByRef A As Object)
   Dim view As Rhino.Display.RhinoView = doc.Views.Find(vp, True)
   If (view Is Nothing) Then
     Throw New Exception("View " & vp & " does not exist")
   End If

   Dim pts As Point3d() = view.MainViewport.GetNearRect()
   If (pts Is Nothing) Then
     Throw New Exception("View " & vp & " is not valid")
   End If

   Dim rec As New Polyline()
   rec.Add(pts(0))
   rec.Add(pts(1))
   rec.Add(pts(3))
   rec.Add(pts(2))
   rec.Add(pts(0))

   A = rec
End Sub


Of course this won't update whenever the view changes. In order to create a proper 'heads-up' display like this you need to define your own Display Conduit and handle each and every redraw yourself.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Very cool. Thanks, David.

Creating a display conduit might be over my head, but this will do the trick for now.

-Jon

Hi,David, Thanks for your reply ,But I have another question,would you please tell me what's wrong?

 

you defined the new rectangle As a   PolyLine   (i.e.  Dim rec As New Polyline())

 

But I defined the rectangle as a Rectangle.what's the difference between them?

there is no wrong message when the grasshopper VB runs,but As long As assigned the rectangle to the output, i cannot find it in the viewport anywhere.

 

what's wrong with that?

 

 

    Dim w ,h As Double

    w = ptA.DistanceTo(ptB)

    h = ptA.DistanceTo(ptD)

    Dim Rtg As New rectangle3d(plane.WorldXY, w, h)

    Dim v As New Vector3d((PtA.X - Rtg.Corner(0).X), (PtA.Y - Rtg.Corner(0).Y), (PtA.Z - Rtg.Corner(0).Z))

    Rtg.Transform(Transform.Translation(v))

 

    A = Rtg

Hi David! Is there any place where is explained how to use the Display Conduit. I found this page on the wiki (http://wiki.mcneel.com/developer/displayconduit) but I do not have clear what to do once I have my own class. I bet I need to register it in some way, but how?

 

Could you put some on light on these? Thanks in advance.

Already solved!!! As easy as register the correct events ..... 

 

This network is a real treasure. Tons of pieces of info spreaded all around that at the end of a couple of days reading become a solution to the problem.....

 

My HUD display is now almost working....

would you be willing to share your work on a HUD display, it sounds extremely interesting!  thank you!

I get an error when I try to run the script, both in Rhino and Grasshopper.

I want to use this to be able to render a view, then make2d and place the vector lines over the rendered image, having the viewport boundary as vectore lines would really speed up the process of placing the lines correctly. For some reason make2d doesn't offer to draw the viewport border, like "export to illustrator" does. I would just use export to illustrator if it had a "hidden line" option. You can't have it all! :P

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service