Surface.SubstractFrom method not working?

Hi guys, I have been trying to create a script, that calculates the area of the room finishes after extracting all openings, curtain walls, etc. In this case, it should work with geometry from a linked file and rooms in a master file. This is why modelling the finishes with dynamo is not an option (I have created another one like that for more conventional cases).

The problem is that once I try to trim multiple surfaces with multiple solids, some of which do not intersect the surface, I get an error message. I tried using a python script for that purpose, but it does not seem to work as well - the output surfaces are identical with the original ones and have the same area:

Here is the python code I used:

I also noticed there is almost identical topic in the forum already: Surface.SubtractFrom bug?

However, the issue does not seem to be resolved. From here: WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free , you can download two sample revit files - MA and a geometry file, as well as the dynamo graph. The idea is to use the script from the MA, where rooms are present.

Any suggestions on how to solve the issue? Thx!

Funny that your code does not work… It looks fine at first glance.
I personally stopped using Surface.SubstractForm() after the post you linked.

If you’re only looking to compute the areas, have you considered something like substracting the areas of the openings for the area of your “big surface” ? Rather than using SubstractFrom and computing the area afterwards ?

1 Like

Well, it actually does not return any error, but still returns identical surfaces… I think it should be an issue with the method itself, if you remove the try: except: part, it only gives a warning that the command was not completed or something. It’s funny, because the post was from 2018, but the issue is not resolved yet :slight_smile:

About your suggestion - to do that I first need to check which openings are adjacent to which rooms, perhaps using the geometry.doesintersect node. However, this is not enough, as sometimes users might want to calculate the area of the wall at a 120 cm height for example, in which case windows’ areas would not have to be subtracted entirely. It’s just an example that this kind of solution is not bulletproof. Sure, It could work, but the script would need many more additional operations and it would work much slower, which is an issue for large projects. I am first trying to solve it in the easiest way possible… if possible

1 Like

Funny… Your Python code works fine for me (I could not test it with your files as my company do not allow me downloading these files). You could even see that the areas are not the same :confused:

1 Like

That’s interesting. Could you please try with a list of solids, at least one of which lies outside the surface’ boundary? I think that’s causing the problem? I guess I could really sort only solids that actually intersect the surface and then it would work just fine.

The central solid was shifted so it does not intersect the surface. Surfaces are still not identical. I fed a list of solids.

Random tought : could you maybe try using Solid.ByUnion on all the solids you have in your model and only use SubstractFrom once ?

That’s a cool idea actually! However, I did a quick test and it did not work… Here it is:

The error I get is the same: “Method not implemented”. Maybe it has something to do with vertical faces of a surface? I really don’t get it

I think that it is Solid.ByUnion, not Solid.Union.

That’'s true, however It’s still the same :frowning: and the error still says: “method not implemented”


I just tried and it does work with horizontal surface (s):

seems like vertical faces are the issue here

So it seems like the method only works for horizontal faces (at least when some of the solids do not intersect the surface)… :slight_smile: @mellouze thx for pointing me in the right direction

I think the best and shortest workaround will be just to use “geometry.intersectall” node, get the areas of all intersections and subtract them from the main surfaces’ areas. That way, I will also know for sure the exact part of the area to be subtracted (not necessarily the whole opening):