algorithmic modeling for Rhino
Hi everyone,
I've recently been trying to learn python in order to automate some external functions from within grasshopper. As an exercise, I've been trying to translate a serpinski triangle script from C# to Python, but as they are two different languages, I've gotten stuck on a specific function.
I can already make a point within python by using Rhino.Geometry.Point3d(x, y, z), but I can't figure out how to use Rhino.Geometry.Transform.Rotation.
The below function takes an input of two Point3d objects (points a and b, in this case).
Two points are then found between the points-- 1/3 between the two and 2/3 between the two points (p1 and p2, respectively). What I am trying to do is rotate p2 about p1. I'm not sure where to introduce p2 into the function I made in order to do this.
--------------
def PtB(a, b):
p1 = a + ((b - a) / 3)
p2 = a + (2 * (b - a) / 3)
Rhino.Geometry.Transform.Rotation(-math.pi / 3, Rhino.Geometry.Vector3d.ZAxis, p1)
--------------
The way this is done in the C# script I am referencing is the following:
Transform trans = Transform.Rotation(-Math.PI / 3, Vector3d.ZAxis, p1)
p2.Transform(trans)
Does anyone have any tips?
Also, I've been working in grasshopper 1.0.0004 in Rhino 6 WIP since Rhino 5 crashes when I try to open the python script editor within the older version of grasshopper.
Tags:
Yes! That fixed the problem. Thanks again for the help.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by