Grasshopper

algorithmic modeling for Rhino

Hi.

I want to toggle through an if statement, if a curve should be mirrored or not.

Should be easy, but I can not do it...

Thanks!!!

Views: 2287

Replies to This Discussion

Hi,

I think this should work for you:

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Attachments:

Thank you very much!

But exactly the same code does not work on my system...

I had to set the Type hint to "ghdoc". Had it on "bool "and "curve".

Great! Thanks again.

i set it 'ghdoc',it works,but why it cant be 'curve'?

rhinoscriptsyntax function rs.MirrorObject() requires a guid as an input, not an object ("Curve" in this case).

Doing the same thing with an object, would require creating a mirror plane, and then a mirror matrix:

import Rhino
import rhinoscriptsyntax as rs

if mirror:
    vec1 = endPt-stPt
    normal_vec = rs.coerce3dvector([0,0,1])
    vec2 = Rhino.Geometry.Vector3d.CrossProduct(vec1, normal_vec)
    mirror_matrix = Rhino.Geometry.Transform.Mirror(stPt, vec2)
    
    a = crv.Transform(mirror_matrix)
    a = crv
else:
    a = crv

This is basically what upper rs.MirrorObject() function does under the hood.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service