liss.dominik writes:
Extend the Blender UI and script your own reference image manager!
Happy scripting 😉
https://www.youtube.com/watch?v=cnz02CCRThQ
liss.dominik writes:
Extend the Blender UI and script your own reference image manager!
Happy scripting 😉
https://www.youtube.com/watch?v=cnz02CCRThQ
14 Comments
Love the way you explain it very detailed and clear even if i'm totally new to blender !
Thanks!
Very happy that my videos are helping you
Well, it's nice to see something like this in Blender and I really appreciate this kind of work - but why? Dont get me wrong, it's a nice tool, but programs like PureRef and Kuadro are way more advanced and production ready.
I really didn't wrote this script to create a new tool. I just wanted to learn how to use the thumbnail dropdown in blender … and I think that the reference manager is a nice example for using those dropdowns This is also the reason why I didn't research any other tools. I just wanted to show the blender community how to use the thumbnails dropdowns and what you could do with it
Hope that answers your question
Whoops - it is a tutorial :D
Forget what I've said - I thought this post is about an addon you've made. I skipped the most of the video and I thought you explained how to use the script. My fault :)
Haha no problem
But thanks for sharing your thoughts :D
Thank you for having shared this script which was very useful ! Besides, the video was very interesting.
However, I have a suggestion : would it be possible to improve the script by adding an interface allowing us to select the pictures repertory ?
Thanks
But I am not quite sure what you mean …
Another suggestion, or a todo list for me when I'll be more confident with blender, can we create a kind of 'viewer node' to see realtime results for procedural nodes in the node editor ( node wrangle is helpfull but not as good as an icon or thumbnail for some nodes ) The idea is to have something like substance designer, but i don't know if its doable...
Thanks a lot for your suggestion!
Unfortunately I don't use nodes in blender … in this case I would have to learn how it works first and then figure a way how to implement your idea. I am afraid that I won't have the time to do all this. But I'll put it on my list
I see that the link is broken on YouTube, and that it is not elsewhere to download. So I typed it over from the video and tried to port it over to 2.80. Don't run the script below because it has some nasty errors, but maybe someone is interested in fixing it further for other users.
import os
import bpy
import bpy.utils.previews
def get_image(filepath):
name = os.path.basename(filepath)
if name not in bpy.data.images:
bpy.ops.image.open(filepath = filepath)
return bpy.data.images(name)
def open_image(self, context):
image = get_image(self.reference_images_enum)
for area in bpy.context.screen.areas :
if area.type == 'IMAGE_EDITOR' :
area.spaces.active.image = image
def get_previews_collection(self, context):
images = []
custom_icons = preview_collections["main"]
directory = "C:\Icons"
i = 0
if directory == custom_icons.my_previews_dir:
return custom_icons.my_previews
for file in os.listdir(directory):
if file.endswitch(".png"):
fullpath = os.path.join(directory, file)
custom_icons.load(file, fullpath, 'IMAGE')
images.append((fullpath, file, fullpath, custom_icons(file).icon_id, i))
i+=1
custom_icons.my_previews = images
custom_icons.my_previews_dir = directory
return custom_icons.my_previews
class ReferenceManagerPanel(bpy.types.Panel):
""" A custom Panel in the viewport toolbar """
bl_label = "Reference Images"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
def draw(self, context):
layout = self.layout
row = layout.row
row.template_icon_view(context.window_manager, "reference_images_enum")
row = layout.row
row.prop(context.window_manager, "reference_images_enum")
preview_collections = {}
def register():
bpy.types.WindowManager.reference_images_enum = bpy.props.EnumProperty(
items = get_previews_collection,
update = open_image
)
preview_collection = bpy.utils.previews.new()
preview_collection.my_previews_dir = ""
preview_collection.my_previews = ()
preview_collections['main'] = preview_collection
bpy.utils.register_class(ReferenceManagerPanel)
def unregister():
del bpy.types.Scene.reference_images_enum
for preview_collection in preview_collections.values():
bpy.utils.previews.remove(preview_collection)
preview_collections.clear()
bpy.utils.unregister_class(ReferenceManagerPanel)
if __name__ == "__main__":
register()
Hi friend I fixed the problem
Cheers
import os
import bpy
import bpy.utils.previews
def get_image(filepath):
name = os.path.basename(filepath)
if name not in bpy.data.images:
bpy.ops.image.open(filepath = filepath)
return bpy.data.images(name)
def open_image(self, context):
image = get_image(self.reference_images_enum)
for area in bpy.context.screen.areas :
if area.type == 'IMAGE_EDITOR' :
area.spaces.active.image = image
def get_previews_collection(self, context):
images = []
custom_icons = preview_collections["main"]
directory = "C:\Icons"
i = 0
if directory == custom_icons.my_previews_dir:
return custom_icons.my_previews
for file in os.listdir(directory):
if file.endswitch(".png"):
fullpath = os.path.join(directory, file)
custom_icons.load(file, fullpath, 'IMAGE')
images.append((fullpath, file, fullpath, custom_icons(file).icon_id, i))
i+=1
custom_icons.my_previews = images
custom_icons.my_previews_dir = directory
return custom_icons.my_previews
class ReferenceManagerPanel(bpy.types.Panel):
""" A custom Panel in the viewport toolbar """
bl_label = "Reference Images"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
def draw(self, context):
layout = self.layout
row = layout.row
row.template_icon_view(context.window_manager, "reference_images_enum")
row = layout.row
row.prop(context.window_manager, "reference_images_enum")
preview_collections = {}
def register():
bpy.types.WindowManager.reference_images_enum = bpy.props.EnumProperty(
items = get_previews_collection,
update = open_image
)
preview_collection = bpy.utils.previews.new()
preview_collection.my_previews_dir = ""
preview_collection.my_previews = ()
preview_collections['main'] = preview_collection
bpy.utils.register_class(ReferenceManagerPanel)
def unregister():
del bpy.types.Scene.reference_images_enum
for preview_collection in preview_collections.values():
bpy.utils.previews.remove(preview_collection)
preview_collections.clear()
bpy.utils.unregister_class(ReferenceManagerPanel)
if __name__ == "__main__":
register()
Oh sorry I don't know why this site removed all spaces
I upload that code in my GitHub:
https://gist.github.com/smkplus/2f599ce29aeae622584f7c234e7b31e9
Hi Seyed,
That is awesome, thanks for the contribution. I'll check it and see if the addon is good to make an article about it.
Regards,
Robert