def stats_scene(self, context): get_addon = "amaranth" in context.user_preferences.addons.keys() if not get_addon: return if context.user_preferences.addons["amaranth"].preferences.use_scene_stats: scenes_count = str(len(bpy.data.scenes)) cameras_count = str(len(bpy.data.cameras)) cameras_selected = 0 meshlights = 0 meshlights_visible = 0 for ob in context.scene.objects: if utils.cycles_is_emission(context, ob): meshlights += 1 if ob in context.visible_objects: meshlights_visible += 1 if ob in context.selected_objects: if ob.type == 'CAMERA': cameras_selected += 1 meshlights_string = '| Meshlights:{}/{}'.format( meshlights_visible, meshlights) row = self.layout.row(align=True) row.label(text="Scenes:{} | Cameras:{}/{} {}".format( scenes_count, cameras_selected, cameras_count, meshlights_string if utils.cycles_active(context) else ''))
def stats_scene(self, context): get_addon = "amaranth" in context.user_preferences.addons.keys() if not get_addon: return if context.user_preferences.addons["amaranth"].preferences.use_scene_stats: scenes_count = str(len(bpy.data.scenes)) cameras_count = str(len(bpy.data.cameras)) cameras_selected = 0 meshlights = 0 meshlights_visible = 0 for ob in context.scene.objects: if utils.cycles_is_emission(context, ob): meshlights += 1 if ob in context.visible_objects: meshlights_visible += 1 if ob in context.selected_objects: if ob.type == 'CAMERA': cameras_selected += 1 meshlights_string = '| Meshlights:{}/{}'.format( meshlights_visible, meshlights) row = self.layout.row(align=True) row.label(text="Scenes:{} | Cameras:{}/{} {}".format( scenes_count, cameras_selected, cameras_count, meshlights_string if utils.cycles_active(context) else ''))
def poll(cls, context): any_lamps = False for ob in bpy.data.objects: if ob.type == "LAMP" or utils.cycles_is_emission(context, ob): any_lamps = True else: pass return any_lamps
def execute(self, context): # Deselect everything first bpy.ops.object.select_all(action="DESELECT") for ob in context.scene.objects: if utils.cycles_is_emission(context, ob): ob.select = True context.scene.objects.active = ob if not context.selected_objects and not context.scene.objects.active: self.report({"INFO"}, "No meshlights to select") return {"FINISHED"}
def execute(self, context): # Deselect everything first bpy.ops.object.select_all(action="DESELECT") for ob in context.scene.objects: if utils.cycles_is_emission(context, ob): ob.select_set(True) context.view_layer.objects.active = ob if not context.selected_objects and not context.view_layer.objects.active: self.report({"INFO"}, "No meshlights to select") return {"FINISHED"}
def draw(self, context): layout = self.layout scene = context.scene objects = bpy.data.objects ob_act = context.active_object lamps = bpy.data.lamps list_meshlights = scene.amaranth_lighterscorner_list_meshlights engine = scene.render.engine if utils.cycles_exists(): layout.prop(scene, "amaranth_lighterscorner_list_meshlights") box = layout.box() if lamps: if objects: row = box.row(align=True) split = row.split(percentage=0.45) col = split.column() col.label(text="Name") if engine in ["CYCLES", "BLENDER_RENDER"]: if engine == "BLENDER_RENDER": split = split.split(percentage=0.7) else: split = split.split(percentage=0.27) col = split.column() col.label(text="Samples") if utils.cycles_exists() and engine == "CYCLES": split = split.split(percentage=0.2) col = split.column() col.label(text="Size") split = split.split(percentage=1.0) col = split.column() col.label(text="%sRender Visibility" % "Rays /" if utils.cycles_exists() else "") for ob in objects: is_lamp = ob.type == "LAMP" is_emission = True if utils.cycles_is_emission( context, ob) and list_meshlights else False if ob and is_lamp or is_emission: lamp = ob.data if utils.cycles_exists(): clamp = ob.data.cycles visibility = ob.cycles_visibility row = box.row(align=True) split = row.split(percentage=1.0) col = split.column() row = col.row(align=True) col.active = ob == ob_act row.label(icon="%s" % ("LAMP_%s" % ob.data.type if is_lamp else "MESH_GRID")) split = row.split(percentage=.45) col = split.column() row = col.row(align=True) row.alignment = "LEFT" row.active = True row.operator( AMTH_SCENE_OT_amaranth_object_select.bl_idname, text="%s %s%s" % (" [L] " if ob.library else "", ob.name, "" if ob.name in context.scene.objects else " [Not in Scene]"), emboss=False).object = ob.name if ob.library: row = col.row(align=True) row.alignment = "LEFT" row.operator( AMTH_SCENE_OT_blender_instance_open.bl_idname, text=ob.library.filepath, icon="LINK_BLEND", emboss=False).filepath = ob.library.filepath if utils.cycles_exists() and engine == "CYCLES": split = split.split(percentage=0.25) col = split.column() if is_lamp: if scene.cycles.progressive == "BRANCHED_PATH": col.prop(clamp, "samples", text="") if scene.cycles.progressive == "PATH": col.label(text="N/A") else: col.label(text="N/A") if engine == "BLENDER_RENDER": split = split.split(percentage=0.7) col = split.column() if is_lamp: if lamp.type == "HEMI": col.label(text="Not Available") elif lamp.type == "AREA" and lamp.shadow_method == "RAY_SHADOW": row = col.row(align=True) row.prop(lamp, "shadow_ray_samples_x", text="X") if lamp.shape == "RECTANGLE": row.prop(lamp, "shadow_ray_samples_y", text="Y") elif lamp.shadow_method == "RAY_SHADOW": col.prop(lamp, "shadow_ray_samples", text="Ray Samples") elif lamp.shadow_method == "BUFFER_SHADOW": col.prop(lamp, "shadow_buffer_samples", text="Buffer Samples") else: col.label(text="No Shadow") else: col.label(text="N/A") if utils.cycles_exists() and engine == "CYCLES": split = split.split(percentage=0.2) col = split.column() if is_lamp: if lamp.type in ["POINT", "SUN", "SPOT"]: col.label(text="%.2f" % lamp.shadow_soft_size) elif lamp.type == "HEMI": col.label(text="N/A") elif lamp.type == "AREA" and lamp.shape == "RECTANGLE": col.label(text="%.2fx%.2f" % (lamp.size, lamp.size_y)) else: col.label(text="%.2f" % lamp.size) else: col.label(text="N/A") split = split.split(percentage=1.0) col = split.column() row = col.row(align=True) if utils.cycles_exists(): row.prop(visibility, "camera", text="") row.prop(visibility, "diffuse", text="") row.prop(visibility, "glossy", text="") row.prop(visibility, "shadow", text="") row.separator() row.prop(ob, "hide", text="", emboss=False) row.prop(ob, "hide_render", text="", emboss=False) else: box.label(text="No Lamps", icon="LAMP_DATA")