5

Is there an option in blender to export (or list out) certain properties of all (selected) objects?

My case is: I have modelled a furniture using real size, metric measurements. Now I want to hand a list of sheet sizes over (x-y-z dimensions of objects in blender) to the carpenter so he would be able to cut the correct sheets for me.

I am looking for an option to do all inside blender, if that isn't possible, an option of some kind of export would be acceptable.

ultiMathei
  • 53
  • 1
  • 5
  • You could get some help from this addon/script (never tried, though) http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Neuro_tool/Measurement – m.ardito Oct 27 '15 at 09:42

1 Answers1

10

It's pretty easy with if you know a little Python.

# import the necessary modules we need
# in our case, blender's python API and python's os module
import bpy, os

# get the current selection
selection = bpy.context.selected_objects

# initialize a blank result variable
result = ""

# iterate through the selected objects
for sel in selection:
    # get the current object's dimensions
    dims = sel.dimensions
    # write the selected object's name and dimensions to a string
    result += "%s - %.03fm x %.03fm x %.03fm\n" % (sel.name, dims.x, dims.y, dims.z)

# get path to render output (usually /tmp\)
tempFolder = os.path.abspath (bpy.context.scene.render.filepath)
# make a filename
filename = os.path.join (tempFolder, "newfile.txt")
# confirm path exists
os.makedirs(os.path.dirname(filename), exist_ok=True)
# open a file to write to
file = open(filename, "w")
# write the data to file
file.write(result)
# close the file
file.close()

Copy and paste the above into Blender's Text editor and press Run Script (Alt+P). It will save the data (object name and dimensions) into your tmp folder.

JaytheHam
  • 3
  • 2
Keith Boshoff
  • 116
  • 1
  • 2
  • Thanks Keith, I have just tried to run the script and it says "Python script fail. Look in the console for now.." – ultiMathei Nov 08 '15 at 16:54
  • great script, but may be unit scale is missing of the scene. – tschmit007 Nov 16 '20 at 11:27
  • This did exactly what I wanted it to do, except I replaced selection = bpy.context.selected_objects with selection = scene.data.objects and used a Find and Replace All function in my text editor on the output file to replace the punctuation with commas to make it valid CSV, and imported into Libreoffice Calc. – David Fogg Dec 06 '20 at 20:47
  • how about in inches? :) – Daniel L. VanDenBosch Jan 28 '22 at 03:01