1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
8 # FUNCTION: Checks if cycles is available
10 return hasattr(bpy
.types
.Scene
, "cycles")
13 # FUNCTION: Checks if cycles is the active renderer
14 def cycles_active(context
):
15 return context
.scene
.render
.engine
== "CYCLES"
18 # FUNCTION: Check if material has Emission (for select and stats)
19 def cycles_is_emission(context
, ob
):
22 if not ob
.material_slots
:
25 for ma
in ob
.material_slots
:
28 if ma
.material
.node_tree
and ma
.material
.node_tree
.nodes
:
29 for no
in ma
.material
.node_tree
.nodes
:
30 if not no
.type in ("EMISSION", "GROUP"):
35 if no
.type == "GROUP" and no
.node_tree
and no
.node_tree
.nodes
:
36 for gno
in no
.node_tree
.nodes
:
37 if gno
.type != "EMISSION":
39 for gou
in gno
.outputs
:
40 if ou
.links
and gou
.links
:
42 elif no
.type == "EMISSION":
48 # FUNCTION: Check if object has keyframes for a specific frame
49 def is_keyframe(ob
, frame
):
50 if ob
is not None and ob
.animation_data
is not None and ob
.animation_data
.action
is not None:
51 for fcu
in ob
.animation_data
.action
.fcurves
:
52 if frame
in (p
.co
.x
for p
in fcu
.keyframe_points
):