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

Extend lines by increment (iterative) stop when collision True [Python]

$
0
0

@ShynnSup wrote:

Hi,

I am trying to achieve a Gilbert Tessellation as an exercise. The idea is simple, lines from random points extend both sides in random directions, until they intersect.

So, the intention is to create a loop that extends each line by a factor, and constantly checks for intersections. The catch is that there is a loop for each line… when the intersection is true for one line, that line stops extending while the others continue.

I am stuck… how can this simple algorithm be achieved?

This is my code so far.

import rhinoscriptsyntax as rs
import ghpythonlib.components as gh

while bool == False:
    bool = gh.CollisionManyXMany(curves)[0]
    extended_curves = rs.ExtendCurveLength(curves, 0, 2, ext)
    if bool == True:
        break

a = extended_curves

For some reason the error reads:

Runtime error (UnboundNameException): name ‘extended_curves’ is not defined
Traceback:
line 11, in script

Which is utterly useless, it tells me the variable “extended_curves” is not defined. It surely has to do with something regarding global and local variables, and the fact that the variable is being defined inside a loop… but how the f*** can I define extended_curves without extending them??

Oh I know: extended_curves = extended_curves. Pff easy.

I am about to destroy my pc. This cant be so hard. I already had a bad time dealing with GUIDs, GEOMETRY, and all that rhino crap.

GILBERT TRY.gh (10.1 KB)

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5846

Latest Images

Trending Articles



Latest Images