algorithmic modeling for Rhino
Hi all, did a little python coding in grasshopper to help try and get a boolean difference to work.
1) the boolean does not work in grasshopper by itself
2) it does work if i manually perform the boolean
3) i'm essentually taking on solid, and a list of difference solids, looping through the difference solids and one by one subtracting them from the solid. each time i take the result of the last difference and subtract the next one.
3) i got it working for python mostly, i can get it to work on smaller groups of the difference solids, but it seems like it times out at the end as if there are to many. i've been trying to introduce error handling but am having a little trouble. ( have been able to add more solids one by one to the list of input solids by manually adding them to the list using list management for the inputs, but if i take those same solids and put them into the new python node with the same node it fails. almost makes me think that the cached results of the previous ones help it not time out or something like that).
4) i am currently getting empty lists out of the boolean operation, i'm trying to get around the empty list by just skipping that difference solid and moving on to the next one while. this is where i'm having trouble. it does not seem to want to move on to the next one... any ideas why this is?
below is my latest code. i've also attached the py file and the gh file with the embeded code, thanks in advance for any ideas and help...
import rhinoscriptsyntax as rs""" siteBox is a single solid box imported
fans is a flattened list of breps
all the fans need to be cut out of the siteBox one at a time since it doesn not work....
"""
def RecursiveDif(siteBox, fans, count):
while (count > 0):
failedDifs = []
if(siteBox != None):
#item in fans at count as index
thisfan = fans[count-1]
#partial dif of sitebox using thisfan
siteBoxModified = rs.BooleanDifference(siteBox, thisfan, False)
#if the boolean fails and is none or siteBox is an empty list then add the fan that didn't work to a list
if(siteBoxModified != None) or not (siteBoxModified):
#sort siteBoxModified by volume and get the biggest one
#replace original box with the largest modified one for the next itteration
siteBox = siteBoxModified
print "siteBox successufly modified"
else:
failedDifs.append(thisfan)
print "boolean failed"
#used for testing if fails with sitebox = none
print (count, "siteBox", siteBox, "siteBoxModified", siteBoxModified)
# regardless of what happens update the count for the next itteration
count = count-1
#output
return (siteBox)
count = len(fans)
envelope = RecursiveDif(siteBox, fans, count)
Tags:
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by