Hi,
I’ve got an issue with Brep.GetVolume() reporting a negative volume that I’m unable to fix
volume_issue.3dm (183.3 KB)
The brep in the file is not solid, calling Brep.CapPlanarHoles() will make it solid yet when trying to get te volume it is a negative value
However If I add the brep to the document first and grab the brep from the document, the volume on that brep is positive. So somewhere in that proces the negative volume issue is fixed.
I’m looking for a way to fix that negative volume without the adding to document loop.
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
id = rs.GetObject('select brep', preselect=True)
brep = rs.coercebrep(id)
capped_brep = brep.CapPlanarHoles(sc.doc.ModelAbsoluteTolerance)
capped_brep.Standardize()
capped_brep.Compact()
#here we get a negative volume : -2283643.74245
print 'capped_brep.GetVolume() ',capped_brep.GetVolume()
#adding the brep to the document and reading the brep back from the doc
capped_id = sc.doc.Objects.AddBrep(capped_brep)
doc_brep = rs.coercebrep(capped_id)
#here we get a positive volume : 2283643.74245
print 'doc_brep.GetVolume() ',doc_brep.GetVolume()
Thanks
-Willem
EDIT for those with a similar issues:
to fix the incorrect solid orientation
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
id = rs.GetObject('select brep', preselect=True)
brep = rs.coercebrep(id)
capped_brep = brep.CapPlanarHoles(sc.doc.ModelAbsoluteTolerance)
if capped_brep.SolidOrientation == Rhino.Geometry.BrepSolidOrientation.Inward:
capped_brep.Flip()
print 'capped_brep.GetVolume() ',capped_brep.GetVolume()