Really thanks for your Effort …
In Macros script I found that Rhino always gives a message if the mesh is open , this message tells me that volume centroid of a mesh is meaningless as it is opened " , it gives me the option to continue any way or not …
but in python script no message appeared , either open or closed mesh … rhino dealt in the same way … and it completes the mission successfully without any message …
I used to check the similarity of the mesh volume centroid data before repairing it (( opened mesh )) & after repairing it (( closed mesh )) , finally I found that there is no difference at all ! … so I guess there is no need to bother ourselves repairing every mesh to obtain its volume centroid … neither think about the volume centroid of an open cube , cause it will be the same as closed one ! …
Area centroid is for 2D meshes … it applies only for x,y … volume centroid is dealing with 3D (( axis )) x,y,z … it’s totally different and if you use area centroid to obtain volume centroid of an open mesh you will not obtain accurate result as shown in your picture … cause it’s totally different aspect !
*** (( out of context ))
I used to write this code to “automatically” import my file from a definite path using python script in order to translate the mesh object then export it to a definite path … but it’s not working … it always ask me to determine the file manually ! … what is the right code to automate this ?!
import rhinoscriptsyntax as rs
rs.Command("_import D:\library\USB\Genesis\prima 4.1.STL")
objects = rs.GetObjects(preselect=True)
for obj in objects:
centroid = rs.MeshVolumeCentroid(obj)
vector = rs.VectorCreate ([0,0,0], centroid)
print "Something is wrong with your mesh. Function terminated"
if obj == objects[-1]:
print "You do not have a mesh in your file. Function terminated"
print "Your file is empty. There's nothing to select"