Problem python intersection

I try to python the form as shown in the image, but when trying that, it seems I am doing something wrong.

What am I doing wrong?
Thank you for your response. :slight_smile:

20190206 problem python intersection 00.gh (10.4 KB)

Looks like line 6 is assigning an array of Breps to ˋremain`. You need a single Brep…?

1 Like

:sweat_smile:
Thank you!
:smiley:

couple items to consider:
1 - be sure to internalize reference geometry in your file
2 - you are using sc.doc…you should probably just use
tolerance = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance
3 - that method returns an array, so in your second “remain”, you need to get the geometry you want, out of the array
4 - for the purpose of clarity, (both for you as you learn rhinoncommon, and for the folks who generously help), get used to writing out the full namespace path. (don’t use import Rhino.Geometry as rg, just write it out).

something like this should work:

import Rhino

tolerance = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance

remain=Rhino.Geometry.Brep.CreateBooleanIntersection(brps[0],brps[1],tolerance)
remain=Rhino.Geometry.Brep.CreateBooleanIntersection(remain[0],brps[2],tolerance)
1 Like

Sorry, now I internalized it.

A question. I implemented the code the same way in a larger script, but it resulted in the red form, which does not comply with the green form as made in another python script.

I want the outcome of the larger script be the same as the green form of the smaller script

Do you know what I am doing wrong?

Thank you for your response :smiley:

20190206 problem python intersection 01.gh (14.8 KB)

there’s a lot going on there…without going through all of it, I would maybe try outputting the three breps and seeing what the boolean order should be…if they can be booleaned to get the desired end result.
also…is this a typo? they look the same to me?
brps=[brepx,brepy,brepz]
brpss=[brepx,brepy,brepz]

1 Like

Thank you for your response.

Yes, brps and brpss are the same. Sorry, that was not necessary.

About the boolean order, they are exactly the same as the one succeeded in the smaller script. I cannot understand by that what I am doing wrong.

Hmmm… it is one of my most difficult ones.

I think I caught a rarity one.

You are doing operations for functions that already exist in gh. So, a way that you could work through the trouble point could be to test it with native gh components to see if you are getting what you want.

In the image above, I added outputs to your component for your breps, (already in your existing code)
I tried using solid intersection, and it didn’t get the desired result, So I tried the inverse, which is solid difference. That worked.
So, from a troubleshooting perspective, you see that there is a path to your desired outcome. Now, you can go back into your code and modify accordingly.

remain = Rhino.Geometry.Brep.CreateBooleanDifference(brps[2],brps[1],tolerance)
remain = Rhino.Geometry.Brep.CreateBooleanDifference(remain[0], brps[0], tolerance)
#remain=rg.Brep.CreateBooleanIntersection(brps[0],brps[1],tolerance)
#remain=rg.Brep.CreateBooleanIntersection(remain[0],brps[2],tolerance)
1 Like

Thank you Hanley :smiley: