Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5823

GHpython: Generartive spawning circles

$
0
0

Hi,

I’m trying to generate circle spawning from one base circle where a circle is spawned from this base circle and from this circle, another circle is spawned etc until the circles fill up the curve boundary.

The whole process will start off with a for loop in which everything is contained in and the initial steps i have are:

  1. for i in count of x (where x is the number of circles we want to generate)
  2. generate the first circle and create a list so that the last item on the list is the one chosen to generate the next circle from
  3. Every time it spawns it has to check if there is a curve intersect with the outside boundary, if yes they it will need to be rotated

The current script I have at the moment is this:

import rhinoscriptsyntax as rs
from Rhino.Geometry import Circle
from Rhino.Geometry import Point3d
from Rhino.Geometry import Vector3d
import Rhino.Geometry.Transform as rgt
import scriptcontext as sc

firstPoint = rs.coerce3dpoint(startPoint) #create firstPoint variable

a = #create a list for output
count = len(a) #create count for list

for i in range of count:

def spawnCircle(firstPoint, recursion): #define circle spawning function

a.append(firstPoint) #adding data to this list

if recursion < 10: #creating a loop within the function
    movedPoint1 = firstPoint + Point3d(10, 5, 0) #moving point function within the loop
    spawnCircle(movedPoint1, recursion + 1) #creating a cap for the loop

spawnCircle(firstPoint, 0) #spawn the new circles

moveVecX = 6 #define vectorX distance
moveVecY = 20 #define vectorY distance
moveVecZ = 8 #define vectorZ distance

moveVector = rs.CreateVector(moveVecX, moveVecY, moveVecZ) #moving according to the vectors above
xf = rgt.Translation(moveVector) #defining the moving variable

a = sc.doc.Objects.Transform(startPoint,xf,bool) #executing the move function

Not sure how to fix it so any help will be greatly appreciated!!

7 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5823

Trending Articles