Python fails to obtain Solid volume

Why is it successful to use the Dyn node to calculate the solid volume obtained by the intersection of two solids, but fails to use the Python node?
(It has been determined that g and V intersect, and the volume of the solid generated by the intersection is valid)
Video & files attached here

Hi,

Volume is a property

try

vol = solid.Volume # or vv.Volume

It would be helpful if you posted screenshots of your issue.

1 Like

@c.poupin Hi, the result is still failure.:persevere:


@Nick_Boyts
Hi, the current problem is that Solid.Volume(vv), vv.Volume, vv.Volume() all fail.:persevere:
And the files are all in the cloud URL of the original post.



Look closely at the output when you skip the volume line and output vv directly - you don’t have a solid - you have a list containing one solid.

And if you look at the documentation for the Geometry.Intersect node you’ll see it’s output is expected to be a list. Imagine intersecting a O shaped solid with a plane - you’d get two circular surfaces, and so Dynamo returns a list.

As such you must iterate over the list of resulting geometry to work with those results. Add a for loop or list comprehension and you should be fine in this instance.

However you should know that directly calling volume in the items in the list will fail in some cases as well. The results of Geometry.Intersect return a list of geometry, not a list of solids. So:

  • Two cuboids stacked will return a surface.
  • Two cuboids arranged like the black squares of a chess board will return a line.
  • Two cuboids which have a common point will return a point.
  • Two cuboids which don’t touch will return an empty list.
  • And two cuboids with overlapping volume will return a solid.

You need to account for each of those possible outcomes if you aren’t certain that 100% of the time you’ll get one type of geometry (based on the intersection results of the node in Dynamo I am not certain you’ll have one geometry type).

3 Likes

OK, I got it.
Thank you very much!