118 lines
3.9 KiB
Python
Executable File
118 lines
3.9 KiB
Python
Executable File
import bpy
|
|
|
|
from bpy.types import Operator
|
|
from bpy.props import (BoolProperty,
|
|
EnumProperty,
|
|
PointerProperty,
|
|
CollectionProperty,
|
|
StringProperty)
|
|
|
|
from .. import fn
|
|
|
|
class RT_OT_select_object_by_name(Operator):
|
|
bl_idname = "rt.select_object_by_name"
|
|
bl_label = "Select Object By name"
|
|
bl_description = "Select object and modifier"
|
|
bl_options = {"REGISTER", "INTERNAL"}
|
|
|
|
object_name: StringProperty(
|
|
name="Object Name",
|
|
description="Name of the object to select",
|
|
default="",
|
|
options={'SKIP_SAVE'}
|
|
)
|
|
|
|
modifier_name: StringProperty(
|
|
name="Modifier Name",
|
|
description="Name of the modifier to show (optional)",
|
|
default="",
|
|
options={'SKIP_SAVE'}
|
|
)
|
|
|
|
def execute(self, context):
|
|
# Check if object name is provided
|
|
if not self.object_name:
|
|
self.report({'ERROR'}, "No object name provided")
|
|
return {'CANCELLED'}
|
|
|
|
# Get the object
|
|
target_object = context.scene.objects.get(self.object_name)
|
|
if not target_object:
|
|
self.report({'WARNING'}, f"Object '{self.object_name}' not found in scene")
|
|
return {'CANCELLED'}
|
|
|
|
# Make it the active object
|
|
## function to make active and selected
|
|
# fn.show_and_active_object(context, target_object, make_active=True, )
|
|
context.view_layer.objects.active = target_object
|
|
|
|
# Handle modifier expansion if modifier name is provided
|
|
if self.modifier_name:
|
|
# Check if the object has modifiers
|
|
if target_object.modifiers:
|
|
# Look for the specified modifier
|
|
modifier = target_object.modifiers.get(self.modifier_name)
|
|
if modifier:
|
|
# Expand only this modifier
|
|
for mod in target_object.modifiers:
|
|
# Collapse all modifiers first
|
|
mod.show_expanded = mod == modifier
|
|
|
|
## Make it the active modifier
|
|
target_object.modifiers.active = modifier
|
|
## Show modifier panel
|
|
fn.set_properties_editor_tab('MODIFIER')
|
|
|
|
return {'FINISHED'}
|
|
|
|
|
|
class RT_OT_info_note(Operator):
|
|
bl_idname = "rt.info_note"
|
|
bl_label = "Info Note"
|
|
bl_description = "Info Note"
|
|
bl_options = {"REGISTER", "INTERNAL"}
|
|
|
|
text : bpy.props.StringProperty(default='', options={'SKIP_SAVE'})
|
|
title : bpy.props.StringProperty(default='Help', options={'SKIP_SAVE'})
|
|
icon : bpy.props.StringProperty(default='INFO', options={'SKIP_SAVE'})
|
|
|
|
@classmethod
|
|
def description(self, context, properties):
|
|
return properties.text
|
|
|
|
def execute(self, context):
|
|
## Split text in list of lines to display
|
|
lines = self.text.split('\n')
|
|
fn.show_message_box(message=lines, title=self.title, icon=self.icon)
|
|
return {"FINISHED"}
|
|
|
|
# Not registered yet
|
|
class RT_reset_path_templates(bpy.types.Operator):
|
|
"""manually reset template to preferences or env settings"""
|
|
bl_idname = "rt.reset_path_templates"
|
|
bl_label = "Reset Render Toolbox Templates"
|
|
bl_description = "Reset Render Toolbox templates from preferences or environment variables if applicable"
|
|
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
|
|
|
# mode : bpy.props.StringProperty(default='ALL', options={'SKIP_SAVE'}) # 'HIDDEN',
|
|
|
|
def execute(self, context):
|
|
from ..properties import reset_scene_path_templates
|
|
reset_scene_path_templates()
|
|
return {'FINISHED'}
|
|
|
|
classes = (
|
|
RT_OT_select_object_by_name,
|
|
RT_OT_info_note,
|
|
RT_reset_path_templates,
|
|
)
|
|
|
|
|
|
def register():
|
|
for cls in classes:
|
|
bpy.utils.register_class(cls)
|
|
|
|
def unregister():
|
|
for cls in reversed(classes):
|
|
bpy.utils.unregister_class(cls)
|