Created
January 3, 2016 10:14
-
-
Save zeffii/efc310fed465f3c55b54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def bool_updates_scene(self, context): | |
ob = context.object | |
visibility = ob.cycles_visibility | |
attributes = ["camera", "diffuse", "glossy", "transmission", "scatter"] | |
state = bool(context.scene.claas_visibility_switch) | |
for attr in attributes: | |
setattr(visibility, attr, state) | |
class ObjectModifier(bpy.types.Panel): | |
bl_label = "ObjectModifier" | |
bl_idname = "ObjectModifier" | |
bl_space_type = 'VIEW_3D' | |
bl_region_type = 'TOOLS' | |
bl_category = "Claas" | |
def draw(self, context): | |
layout = self.layout | |
scene = context.scene | |
cscene = scene.cycles | |
ob = context.object | |
if not context.object: | |
layout.row().label('no active objects') | |
# finish drawing early | |
return | |
cob = ob.cycles | |
visibility = ob.cycles_visibility | |
layout.label(text="Ray Visibility:") | |
flow = layout.column_flow() | |
vis_icon = ["PROP_OFF", "PROP_ON"][int(scene.claas_visibility_switch)] # 0 or 1 | |
flow.prop(scene, "claas_visibility_switch", text='all', icon=vis_icon) | |
flow.prop(visibility, "camera") | |
flow.prop(visibility, "diffuse") | |
flow.prop(visibility, "glossy") | |
flow.prop(visibility, "transmission") | |
flow.prop(visibility, "scatter") | |
def register(): | |
bpy.types.Scene.claas_visibility_switch = bpy.props.BoolProperty( | |
update=bool_updates_scene | |
) | |
bpy.utils.register_module(__name__) | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
del bpy.types.Scene.claas_visibility_switch | |
if __name__ == "__main__": | |
register() |
Author
zeffii
commented
Jan 3, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment