Skip to content

Instantly share code, notes, and snippets.

@AlansCodeLog
Last active August 24, 2019 17:27
Show Gist options
  • Save AlansCodeLog/81b5ff298a968c7a1673bf7badf2b533 to your computer and use it in GitHub Desktop.
Save AlansCodeLog/81b5ff298a968c7a1673bf7badf2b533 to your computer and use it in GitHub Desktop.
Blender Scripts Add-on #blender
# My Scripts Panel
# Simple tab in tools panel with my most used scripts.
bl_info = {
"name": "Scripts Panel",
"category": "User Interface"
}
import bpy
from bpy.types import Menu, Panel, UIList
# Set where we want panel (as tab of tools panel)
class View3DPanel():
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
# Add Panel
class ScriptsPanel(View3DPanel, Panel):
bl_label = "Toggles"
bl_category = "Scripts"
#List toggle scripts.
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.operator("object.visibility_viewport_to_render")
col.operator("object.visibility_render_to_viewport")
#Actual scripts.
class OBJECT_script_1(bpy.types.Operator):
bl_label = "Viewport -> Render Visibility"
bl_idname = "object.visibility_viewport_to_render"
bl_description = "Sets render visibility of all objects to viewport visibility."
def execute(self, context):
for ob in bpy.context.scene.objects: ob.hide_render = ob.hide
return {'FINISHED'}
class OBJECT_script_2(bpy.types.Operator):
bl_label = "Render -> Viewport Visibility"
bl_idname = "object.visibility_render_to_viewport"
bl_description = "Sets rviewport visibility of all objects to render visibility."
def execute(self, context):
for ob in bpy.context.scene.objects: ob.hide_render = ob.hide
return {'FINISHED'}
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment