This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/scripts/startup/bl_ui/properties_physics_geometry_nodes.py
Lukas Tönne 3e888d77ba Geometry Nodes: Simulation calculate to frame operator
Adds a new operator that resets caches and then iterates from the start
frame to the current frame in order to update caches.

Pull Request: blender/blender#107627
2023-05-08 13:41:21 +02:00

52 lines
1.5 KiB
Python

# SPDX-License-Identifier: GPL-2.0-or-later
from bpy.types import (
Panel,
)
from bpy.app.translations import pgettext_iface as iface_
class PHYSICS_PT_geometry_nodes(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "physics"
bl_label = "Simulation Nodes"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def geometry_nodes_objects(cls, context):
for ob in context.selected_editable_objects:
if any([modifier.type == 'NODES' for modifier in ob.modifiers]):
yield ob
@classmethod
def poll(cls, context):
return any(cls.geometry_nodes_objects(context))
def draw(self, context):
layout = self.layout
if len(context.selected_editable_objects) > 1:
calc_text = iface_("Calculate Selected to Frame")
bake_text = iface_("Bake Selected")
else:
calc_text = iface_("Calculate to Frame")
bake_text = iface_("Bake")
layout.operator("object.simulation_nodes_cache_calculate_to_frame", text=calc_text).selected = True
row = layout.row(align=True)
row.operator("object.simulation_nodes_cache_bake", text=bake_text).selected = True
row.operator("object.simulation_nodes_cache_delete", text="", icon='TRASH').selected = True
classes = (
PHYSICS_PT_geometry_nodes,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)