Just bought a 3D Resin Printer and so wanted to get a macro to find the volume so I could calculate the cost to print the part and ended up with this. Simple, but maybe it sparks the idea for someone.
Note! The code assumes you are running FreeCAD in Metric mm/kg/s units. If you'd like to be, go to Edit>Preferences>General>Units and under Unit System: select Standard (mm/kg/s/degree) and we'll have one less Imperial minion. Cheers!
Macro:
Code: Select all
print(" ")
print("----- Physical Properties of Selected Object for 3D Resin Printing -----")
target_object = App.ActiveDocument.ActiveObject
model_volume = target_object.Shape.Volume/(10**3)
print("Model Volume: " + str(round(model_volume, 3)) + " cm^3")
dollars_per_gram_eSun3D_Hard_Tough = 40/1000 # $ / g
density_eSun3D_Hard_Tough = 1.15 # g / cm^3
print("3D Printer Resin Density (eSun3D Hard Tough): " + str(round(density_eSun3D_Hard_Tough, 3)) + " g/cm^3")
model_mass = density_eSun3D_Hard_Tough*model_volume
print("Model Mass: " +str(round(model_mass, 3)) + " g")
print("Dollars per Gram (eSun3D Hard Tough): $" + str(round(dollars_per_gram_eSun3D_Hard_Tough, 2)))
total_cost = model_mass*dollars_per_gram_eSun3D_Hard_Tough
print("Cost to Print (eSun3D Hard Tough): $" + str(round(total_cost, 2)))