I have encountered a bug (?) this afternoon (at least I’m guessing it is one). Here it is :
I have a list of surfaces representing walls, and list of surfaces representing openings (doors and windows).
I want to cut the openings off the walls.
My idea was to : use Surface.Thicken (inputs = surfaces that represent the openings), use Solid.ByUnion to get a unique solid, finally use Surface.SubtractFrom (surfaces = walls, trimming entities = solids from Surface.Thicken).
These two nodes have always worked perfectly fine for me, until now. It was the first case I have ever encountered that presents two openings (n°0 and n°4) which share a corner (and a corner only). I did not get the list of Surfaces I was expecting, rather a list filled with Empty lists. The problem also happens if those two surfaces are the only surfaces in the list…
FYI, a way to bypass the problem is to use Surface.SubtractFrom in a Python loop : you have to compute the result opening by opening (and cannot. Note that this solution may result in a crash of Dynamo if the project is too big.
Still interested if any one can explain this behaviour or give an alternate solution.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
origi_surf = IN[0]
opns = IN[1]
result = origi_surf
for opn in opns:
result = Surface.SubtractFrom(result,opn)[0]
OUT = result
My Python script was designed to work with one surface only and its openings, not a list of Surfaces with their respective openings.
The script I used is the same you used in your screenshot.
The fastest way to bypass the problem would be to encapsulate the Python Script into a custom node and feeding it the lists with the appropriate levels.
The cleanest way to do it would be to re-write the python script and add an additional loop.
Hi
I developed Python Script so that it can subtract a list of surface with a list of solid.
However, error occur when some surface does not intersect with solid, or does not penetrate the solid.
Could you please check it? I uploaded the code here.
My python script:
============================================
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
origi_surf = IN[0]
opns = IN[1]
i = 0
j = origi_surf
result = j
for j in origi_surf:
for opn in opns:
result[i] = Surface.SubtractFrom(origi_surf[i],opn)[0]
i +=1
OUT = result
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
origi_surfs = IN[0]
solids = IN[1]
result = []
for surf in origi_surfs :
new_surf = surf
for sld in solids :
new_surf = Surface.SubtractFrom(new_surf,sld)[0]
result.append(new_surf)
OUT = result