Skip to content

Instantly share code, notes, and snippets.

@iLikeKoffee
Last active November 27, 2025 08:58
Show Gist options
  • Select an option

  • Save iLikeKoffee/6c622f0b4578b675a8806d6dd8f30938 to your computer and use it in GitHub Desktop.

Select an option

Save iLikeKoffee/6c622f0b4578b675a8806d6dd8f30938 to your computer and use it in GitHub Desktop.
Blender list cut
# Thanks to Tim Huckaby (@timhuckaby), see https://github.com/TimHuckaby/Blender-Cut-List
#(c) 2022 Tim Huckaby (@timhuckaby)
#
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# import the blender's python API and python's os module
import bpy, os
def get_parent_collection(collection_name):
for coll in bpy.data.collections:
if collection_name in coll.children.keys():
return coll.name
return None
def get_full_collection_name(collection_name):
parent_name = get_parent_collection(collection_name)
if parent_name is None:
return collection_name
return get_full_collection_name(parent_name) + '.' + collection_name
def get_full_object_name(obj):
try:
collection_name = get_full_collection_name(obj.users_collection[0].name)
return collection_name + '.' + obj.name
except Exception as e:
print(e)
return 'error ' + e
# select all the mesh objects in the scene
objects = bpy.context.scene.objects
for ob in objects:
ob.select_set(ob.type == "MESH")
# 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; convert from meters to millimeter and round to 1 decimal places
dims = sel.dimensions
x = float(round(sel.dimensions.x * 1000, 1))
y = float(round(sel.dimensions.y * 1000, 1))
z = float(round(sel.dimensions.z * 1000, 1))
[height, width, length] = sorted([x, y, z])
# write the selected object's name and dimensions to a string for the file output
# if you want to output to a txt file to open in word, notepad, etc. then use this line:
# result += "%s - %.02fin x %.02fin x %.02fin\n" % (sel.name, x, y, z)
# if you want to output to a csv file to open in excel so you can sort, etc. then use this line:
result += "\"%s\" , %.02f , %.02f , %.02f , \"%s\"\n" % (get_full_object_name(sel), length, width, height, sel.active_material.name)
# get path to render output (ie: C:\Users\TimHuckaby\)
tempFolder = os.path.expanduser('~')
# make a filename
# if you are creating a text file for word, notepad, etc uncomment this next line:
# filename = os.path.join (tempFolder, "Documents\CutList.txt")
# if you are creating a csv file for excel uncomment this next line:
filename = os.path.join (tempFolder, "Documents\CutList.csv")
# confirm path exists
os.makedirs(os.path.dirname(filename), exist_ok=True)
# open the file to write to
file = open(filename, "w")
# write the data to file
# write the header for excel. if you are creating a txt file you can comment out this next line:
file.write("Name, Length, Width, Height, Material\n")
file.write(result)
# close the file
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment