Ghpython incremental loop question

Hey good-looking friends,

I am trying to learn ghpython, I tried to:

  1. divide the first curve (use the Midpoints from each segment as the "destination points),
  2. move the second curve to each and every destination points provided),
  3. rotate at each points


I am really grateful if you can help me understand a few question that I am currently having:
1.I used “incremental loop” in all three steps in order to get the similar effect as “Graft” data datatree in regular gh, but I don’t understand the “Output” generated by the loop, i.e. the amount of data will increase following its index number, instead of one geometry at each places as I intended:
image

  1. Could you please take a look at my current script (inside Ghpython)
    python question.gh (115.1 KB)

is there anyway to streamline the whole process e.g. I don’t need to loop to convert the GUID to Point3D everytime and I don’t need to “loop” and “append” in order to move geometries,

I appreciate your help~~~

Tom

So how did it go?

I am wondering if someone can help me with the question I have, (learning following the youtube video :mask: :mask:)

really appreciate your help again!

If you’re learning use Rhinocommon where possible also read docs, that’s the best way to get your head around this.

import Rhino.Geometry as rg
import math
#Get crv parameters t for each point
params = crv1.DivideByCount(div,True)
#Get list of points for each t
pts = [crv1.PointAt(p) for p in params]

#Output crv lst
crvs = []
#Get crv2 mid pt
crv2_midPt = crv2.PointAt((crv2.Domain[1] - crv2.Domain[0]) / 2)

#For each point, copy the curve to point, rotate if you want 
for pt in pts:
    vec = pt - crv2_midPt
    crv = crv2.Duplicate()
    crv.Translate(vec)
    crv.Rotate(math.radians(rot),rg.Vector3d(0,0,1),pt)
    crvs.append(crv)

python question.gh (117.6 KB)

You didn’t use any rs., this is nothing but rg. ~~~~

Is there any chance that you can whip one up with nothing but rs. :joy: :joy: :joy: :joy:

Wkarnowka, You Da BOSS~~~

Your humble student: Ranran
(just feelin that I have to understand rs. first in order to step up to rg.)

Think of it like this! rhinoscriptsyntax is for Rhino and rhinocommon (API) for Grasshopper.

1 Like

Rhinoscriptsyntax library was initially created to help people to transition from RhinoScript (Visual Basic) to Python since you’re not transitioning just learning proper classes, methods, properties etc.; Since we’re doing analogies - if want to play the piano, you definitely do not start with the keyboard. Build good habits from the start, it will pay off in the future. Rhinocommon is also a lot faster (as Rhinoscriptsyntax is just a wrapper written in Rhinocommon), and unlike RS makes you understand a lot of the concepts necessary anyway.

Otherwise or if you’re in rush just use the canvas, nothing you’re doing so far can’t be quickly sketched out in Grasshopper

Best,
WK

1 Like

Thank ya’ll so much for the help and advice~~~