Grasshopper

algorithmic modeling for Rhino

Hello everyone

I want to write a component,Rhino objects follow the camera rotation,Like gif, people are always facing the camera.

I wrote the C# script, but it didn't work properly

Thanks for any advice.

                                                                                           ——NARUTO

Views: 2069

Attachments:

Replies to This Discussion

This is my code

Attachments:

If you want to draw the same geometry over and over again just in different places, it makes more sense to transform the projection than the geometry. It's just way quicker.

I didn't look too deeply into your code (sorry), but I made this proof-of-concept, hopefully as simple as possible.

Attachments:

Thank you very much for your advice,I solved the problem.

But now I need to create a GhObject in the current document, if not my script does not run

While not a c# solution, ladybug has an orient to camera component.   I very slightly modified for our use to include the option to rotate in XYZ or XY.

import scriptcontext as sc
import Rhino as rc

cameraX = sc.doc.Views.ActiveView.ActiveViewport.CameraX
cameraY = sc.doc.Views.ActiveView.ActiveViewport.CameraY
cameraZ = rc.Geometry.Vector3d(0.0,0.0,1.0)

def main(_pts):
if _XYorXYZ == True:
oriented = rc.Geometry.Plane(_pts, cameraX, cameraZ) #2D
else:
oriented = rc.Geometry.Plane(_pts, cameraX, cameraY) #3D
return oriented

if _pts:
oriented = main(_pts)

Thank you Chris Hanley. This method is perfect

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service