Skip to content

Instantly share code, notes, and snippets.

@mireq
Created October 22, 2016 11:52
Show Gist options
  • Save mireq/ba8e48607e40248b3bc9884306dcd5cb to your computer and use it in GitHub Desktop.
Save mireq/ba8e48607e40248b3bc9884306dcd5cb to your computer and use it in GitHub Desktop.
Blender material preview in node editor
import bpy
class PreviewPanel(bpy.types.Panel):
bl_label = "Material preview"
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
@classmethod
def poll(cls, context):
return context.active_object is not None and context.object.active_material is not None
def draw(self, context):
ob = context.active_object
self.layout.template_ID_preview(ob, "active_material")
#self.layout.template_preview(ob.active_material)
def register():
bpy.utils.register_class(PreviewPanel)
def unregister():
bpy.utils.unregister_class(PreviewPanel)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment