How to get the above message returned to the python code? I need to reuse it within the code. I have already tried doing it with the rs.SurfaceVolume() command, but it fails due to the surface being open, not closed. I have 2 naked edges in my geometry which I cannot get rid of and so I cannot close the surface. Increasing absolute tolerance did not help. For this reason, I must run rs.Command() rather than rs.SurfaceVolume.
First of all be aware that the Volume command likely will not yield correct results with non-solid input.
below is a quick setup in python to get the combined volume of all (poly)surfaces
import rhinoscriptsyntax as rs
ids = rs.SelectedObjects()
total_volume = 0
for id in ids:
result = rs.SurfaceVolume(id)
if result: total_volume += result[0]
print total_volume
You could also add code to collect if the result is None so you know how much and for what objects no Volume is calculated.
Thank you very much for your reply. I am aware that the Volume command result may not be valid. In my case, the opening in the surface is tiny, and the error tends not to be too big. I am double checking my results at a later stage so that is not a problem.
I only have one polysurface in my project so the method you proposed does not solve my problem. It is a nice way of getting a feedback but after all I do need the volume to be calculated for that open polysurface.
Is there any way to return the Volume command message back to the python code?