Surface.SubtractFrom bug?

Hi people :slight_smile:

Files :
Desktopsurfs_opn.sat (11.0 KB)
Desktopsurfs_walls.sat (21.7 KB)
subtract.dyn (18.0 KB)

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).

Here are the elements :

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… :confused:

Is this a known issue ? Am I missing something ?

Expected output :

Best,

Mustapha

Hi again,

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.

(Should I report this at the GitHub ?)

Best,

Mustapha

1 Like

Reported at GitHub :

How did you bypass the problem. Could you share the python script?

Hi,

Here is a file that sums up everything (download link under the figure).

SubtractBug.dyn (19.1 KB)

Here is the python script of the .dyn :

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
2 Likes

I try to use python to bypass the problem but the result is empty list.
Could you show the python of your project in the topic?

Hi,

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.

2 Likes

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

=================================================

  1. No error when surfaces penetrate the solids.
  2. Error when surfaces touch the solids.
  3. Error when surfaces do not penetrate the solids.

TestSubtractfrom.dyn (8.3 KB)Preformatted text
Revit file:

Hi,

Try replacing your Python Script by this script :

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
1 Like

still get error in the scenarios 2 and 3.