Python guide issue

I want to see if some curves are intersect. What am I doing wrong?

guide (6.6 KB)

Do you need a coerceguid() method ?

1 Like

that would work if the objects are in the Rhino document. I would use rhinocommon for it:

import Rhino.Geometry as rg

for p in plns:


for re in rects:
    ie = rg.Intersect.Intersection.CurveCurve(re.ToNurbsCurve(), asdf.ToNurbsCurve(), 0.001, 0.05);

    if ie:
        print True
    else: print False
1 Like

I was thinking of that to, but the method did not work in my case somehow.

I am trying something. Preventing from the offsets(red) intersecting with the original shape size rectangles (black).

I do not know why, but it just does not recognize the intersection (line 27-45).
After line 47 the offset of the curves begin. Per plane a rectangle is created, and per side of the rectangle the possible offset is evaluated.

What am I doing wrong?

offset (28.5 KB)

Hey @ForestOwl, taking a look at your code right now, I must admit its a bit hard to read. I don’t understand your zipped values and what you want to do with them at all, i wrote a new ghpython component showing you a method to achieve what i think you want to achieve.
feel free to ask or complain if this is not a good answer :wink:

offset (12.7 KB)

Shame on me for not reading your question right… you want the offsets to stop at the inner rectangles.

offset (17.8 KB)

1 Like

Vielen Dank :sunglasses: !~Hervorragend :face_with_monocle:

Thank you :smiley:

A small question. Konnen Sie mir sagen was diesen [::] machen? ‘Holding offset arrays?’ How?

ah sorry yes, [::] is a shortcut in list slicing, i give you an example:

myList = [1, 2, 3, 4]
print myList[1:] #->[2, 3, 4]
print myList[:-1] # ->[1, 2, 3]
print myList[::] # -> [1, 2, 3, 4]

so essentialy [::] is a really short was of copying the content of one list to another list. I like to use it when i plan on changing lists after i declare them because if you just do this you get problems:

myList = [1, 2, 3]
myOtherList = myList
myList[0] = 8
print myList # -> [8, 2, 3]
print myOtherList # -> [8, 2, 3]

As you see when you declare lists just with an “=” they will both change when you change its content and as, in the code in line 49 we change the content of rectArrOffset, we would also change the content of rectArrBase.

Here is somethign to read up on copying lists in python:


Hey again :smiley:

I have two more questions

[1] I am doing something wrong I guess,
I tried a different configuration (part below in image).

[2] I also tried something else, trying to use a bigger dOffsetDistance, I cannot resolve it. Do you might know how to do that? I do not know where to put break (part on top in image).

offset (22.8 KB)

hey @ForestOwl, in your second definition there are multiple undefined variables, so i can’t really figure out what you are trying to do there, also i see that now you have boxes and rectangles in 3d space, so the 2d case was just simplifierd but actually you want a 3d algorithm?

can you specify a bit more what is your desired outcome?

On the topic of dOffsetDistance, the name is a bit bad, its more like a tolerance, so the smaller you make this parameter the closer your offset gets to the inner rectangle, do you want perfecti intersection or shoukd there be a small gap?

Thank you for your response :smiley:

I want the green lines expanded based on an ‘max distance offset.’ But, I want that when they collide with a boundry brep they stop expanding,

because I do not want to let the rectangles (later converted to surfaces) cross the boundry breps.

offset (41.3 KB)

So you want each selected, green curve to be offset, until it collides with one of the other offset curves (previously also green curves) in the system, or until a maximum offset distance is reached?
If so, this could be achieved iteratively, by looping all the curves, offsetting each one a tiny bit, checking if it collides with any of the other curves and if not replace the previous curve with the offset on, and so fourth until the maximum offset distance is reached, or it finally intersects with another curve.

Check the attached grasshopper definition for a way of doing what i think you want to do

offset (39.7 KB)

Thank you :smiley: @lando.schumpich

What is the thought behind sqrt?

@diff-arch I wanted to let it offset based on difference maxs stopping expanding when hitting a boundry brep.

yes I know, but I cannot understand what the purpose in the script for it is

I find it always very interesting how you guys script scripts, I always try to understand the scripts you help me with, so I can do it by myself

maybe this rough sketch can give you an idea

the line between the rectangle corners forms a right triangle with the offset distance line, so when comparing distances we have to multiply by sqrt(2)

1 Like