I’m working on an assembly and wish to export the Volume Centroids as a csv file. No problem, I can do that. But can I add my own properties, particularly a weight/mass for each item, so I can do some centre of gravity calculations with the exported data in a spreadsheet? Or am I going to have to add them manually in the spreadsheet?
Thanks in advance.
Tim
PS working in Both Rhino 4 and 5, although for this job I would prefer V4. Don’t ask…
This should be easily scriptable… Someone might even already have one of these floating around. If you need real weight, you might have to supply a material density which can be multiplied by the volume calculation… Do you need any other object data exported?
The weight is always given in Newtons, no matter what unit system you have. This could easily be changed into KiloNewtons (just additionally multiply the line 84 with “0.001”. Like so: weight = mass * massFactor * 9.81 * 0.001
I took the metal alloy material densities data from here. If you want to add more materials, you could do that by yourself. Just add the material’s name at the end or beginning of list (line 11 in the attached .py file) and its respective density to the list in the line 12.
Apart from exporting a data into .csv file, it also adds labels of object’s number’s and volume centroid points to the Rhino file:
Tried to make a button out of it but an issue emerged. Seems like once, the function gets to the line: unitsystemIndex = rs.UnitSystem() instead of further continuing to execute the code, it quits the function and opens “Document Properties” window. Is that some sort of a bug? @stevebaer any thoughts?
Hi djordje, I have had a go with your script, and edited it a little to my own purposes, but having never worked in Python before, I am a bit out of my depth here!! Is there any way I can change things so instead of each item being labeled obj01 etc, it extracted the appropriate part name from the part properties? It would be wonderful to label each line as, for example, bolt01, hull left, wheel, etc, directly, rather than having to edit the imported data in Excel.
Thanks in advance,
Tim
ps I’ve started reading the Python for Rhino 5 document already!
By “part name from part properties” you mean “Object name” (set by using “SetObjectName” command)?
If that is so, then try the edited version: volumeMassWeightCentroids2.py (7.5 KB)
For those objects which do not have their names set, the old labeling of “obj i” will remain. Hope this helps: