Curve Intersection - Python

Like shown in image im trying to do this -

test1.gh (10.0 KB)

  • explode the curve into segments.
  • Find their midpoints.
  • Move them outward in increasing steps of 10 units.
  • Stop moving a segment when it intersects a plot and add it to the list “z”
  • The green plots are the ones that ideally have to be in the z list and red ones omitted.
  • I have attached the gh.file below as there seems to be a problem in the output im recieving

@eirannejad I’d be highly grateful if you could respond to my query

It’s not very clear what you are trying to achieve based on the description. What’s intersecting with ‘plot’?

Let’s say the bigger linear rectangle curves are “green” and all the smaller rectangles around them are “plots”

I have exploded the green, found their centres and got vector direction of each exploded curve by getting vector between the exploded curves midpoint and the green’s centre.

Then I’m trying to move the exploded curves of green in the vector direction I got before in an increment of 10 steps 10 times, so it moves 10 units with every iteration. By the time it reaches the final iteration of 100 units, if it happens to intersect any “plot” I’d want the exploded curve to stop moving forward and add the plot it intersects with to a NEW LIST

Id be highly grateful if you could check the gh.file I attached above and help me rectify where I’m going wrong

@eirannejad Can you please look into this

From my point of view, you don’t need any scripting. Here might be what you are looking for:


test1.1.gh (23.9 KB)

1 Like

Thank you for the response but I’d want to do it through python only. Id be highly grateful if you could help me figure this out through python

@eirannejad I’d really appreciate it if you could help me resolve it through python

@eirannejad @Eric27 ???

I’d suggest to go through some tutorials using Python and Grasshopper

just recently I discovered this youtube channel, and it was a wonderful learning journey: https://www.youtube.com/@patrickdanahy

this is just one among many, I’d start from there: https://www.youtube.com/watch?v=6spW9SRmi9Y&list=PL3pEWvJXesJ_IwMtRXYjfcoQlIpZoVI2r&index=7

1 Like

Basically, if you want to animate something in GHPython, you need to implement an “animator” first, something that drives the animation, commonly referred to as “counter” or “timer”.
This is usually done by recomputing the GHPython component and storing persistent data that you want to keep between iterations in globals() or the sticky dictionary. When the GHPython component recomputes, all your Python code goes out of scope and everything gets cleaned up, that’s why you need the latter step.

Here’s an example of a simple counter that, well counts up to a certain number of seconds.

timed-counter

I use globals() to make the needed variables persistent between recomputes.

custom-timed-counter-0.2.gh (5.6 KB)

To make this clearer, you can use the same principle to move geometry, by for instance moving points with vectors each step/iteration and storing their positions between steps.

1 Like