Skip to content

Instantly share code, notes, and snippets.

Forked from anonymous/
Last active September 23, 2020 03:44
Show Gist options
  • Save zeffii/de5f7112bf08bd794b04 to your computer and use it in GitHub Desktop.
Save zeffii/de5f7112bf08bd794b04 to your computer and use it in GitHub Desktop.
bl_info = {
"name": "FILL ME MO",
"author": "",
"version": (0, 1),
"blender": (2, 7, 6),
"category": "3D View"
import os
import bpy
from bpy_extras.io_utils import ExportHelper
# adding a PropertyGroup helps keep the Scene namespace clean.
# instead of adding 10 properties directly to Scene, you only
# add 1 group, which itself has a dot(.) lookup to get individual
# properties
class MyAddonProperties(bpy.types.PropertyGroup):
some_identifier = bpy.props.StringProperty()
some_integer_prop = bpy.props.IntProperty()
# ...etc ..
class WMFileRemover(bpy.types.Operator):
bl_idname = "wm.remove_file"
bl_label = "Remove File"
def execute(self, context):
fp = context.scene.my_addon.some_identifier
if fp:
print('os.remove(', fp, ')')
else:{'ERROR'}, 'filepath is an empty string')
return {'FINISHED'}
class WMFileSelector(bpy.types.Operator, ExportHelper):
bl_idname = "something.identifier_selector"
bl_label = "some folder"
filename_ext = ""
def execute(self, context):
fdir =
context.scene.my_addon.some_identifier = fdir
class WMFilePanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
def draw(self, context):
layout = self.layout
scn = context.scene
# ui
col = layout.column()
row = col.row(align=True)
row.prop(scn.my_addon, 'some_identifier', text='directory:')
row.operator("something.identifier_selector", icon="FILE_FOLDER", text="")
col = layout.column()
def register():
bpy.types.Scene.my_addon = bpy.props.PointerProperty(type=MyAddonProperties)
def unregister():
del bpy.types.Scene.my_addon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment