How to project a curve in viewport direction onto a brep?


#1

Hi, i have an outline of a mesh and want to project the polylines onto a brep. The problem is that i want to project in perspective mode into screen direction but the “Rhino.Geometry.Curve.ProjectToBrep()” unfortunatly does not take a vieport as input. Only a single 3dVector…
Why is it possible to project a mesh outline in screen direction onto a plane (GetOutlines(RhinoViewport)) but not from a plane onto an object into screen direction?

maybe someone can give me hint…
Johannes

btw.: double curved screens with parallel projection is not an option :slight_smile:


#3

Hey, thats excactly what i am looking for. I think there are methods in the rhinocommon sdk to solve that in my application.

Thanks,
Johannes


#4

Sorry, it was late last night and I realized the post had some wrong info, which is why I deleted it…

The projection is a bit more complex than I described in the original post, so today, in between things, I decided to script it in Python. Pascal has a VB Rhinoscript somewhere that does more or less the same thing, but I decided to write mine from scratch as a learning experience.

The attached (first draft) will project one or more curves onto one or more surfaces or polysurfaces using the perspective projection in the active viewport. It does so by:

  • finding the camera-target vector and camera plane
  • finding the bounding box of the target objects
  • creating a plane behind the bounding box of the objects parallel to the view plane
  • copying the curve objects to this plane at the same time scaling them up according to the perspective view angle
  • extruding the copied curves back to the camera point (extrude to point)
  • finding the intersection between the extruded surface(s) and the target object(s) (if any)
  • the intersections represent the projection in perspective of the input curves. In theory in the active perspective viewport they should line up perfectly with the input curves…

As this is written partly with RhinoCommon, no geometry is added to the file until the final step, so if the user bails out in the middle or it fails, no remnants should be left behind (that was part of the reason for RhinoCommon).

Anyway, feel free to try it out, let me know if it breaks, I haven’t tested it extensively.

–Mitch

ProjectAlongViewPerspective.py (2.6 KB)


One point projection
(Pascal Golay) #5

Hi Johannes - in case it still helps, here is a RhinoScript -

To use the script, extract and save the .rvb file from the attached zip archive, then drag and drop the saved rvb over an open Rhino V4 or v5 window. This will load the script, set it up to load on startup in the future and register the alias

ProjectPersp
ProjectFromPt

that will run the script much like a regular command. An alias can be typed or added to a toolbar button or keyboard shortcut (F-key).

ProjectPersp (8).zip (1.3 KB)

-Pascal


#6

Hey Mitch, thanks alot! The “extrude to point” method and “scaling outlines on the far plane according to the perspective” was missing in my operation. Very nice.
It is almost done. I just need to find some time to finalize it in my c# plugin. That will save alot of time :wink:

Johannes


#7

Hey Pascal,

that are two nice functions. Would be nice to see it on our website rhinoscript.org :wink: Maybe you can take a look on it.

Johannes


(Pascal Golay) #8

Hi Johannes- feel free to use it there- there are some more goodies here:

http://wiki.mcneel.com/people/pascalgolay

help yourself!

-Pascal