I am currently trying to have the parameter set to Three Levels by default in an InputHelper window. Unfortunately, I can't access the value.
For example, if I try to access bpy.data.screens[“temp.010”].params like in the picture, I get the error that screens has no params.
Let's say I have this basic code to register a UI Panel and with a click on a button, I'm opening a File Browser Window to Import some files. I now want this window to have Resursions: Three Levels enabled by default.
import bpy
import os
from bpy.types import Operator, Panel
from bpy.props import StringProperty, CollectionProperty
from bpy_extras.io_utils import ImportHelper
class ImportDXF(bpy.types.Operator, ImportHelper):
bl_idname = "object.import_dxf"
bl_label = "Import DXF"
bl_options = {'REGISTER', 'UNDO'}
filename_ext = ".dxf"
filter_glob: StringProperty(
default="*.dxf;",
options={'HIDDEN'},
)
files: CollectionProperty(type=bpy.types.PropertyGroup)
def execute(self, context):
folder = os.path.dirname(self.filepath)
for file in self.files:
print(f"Importing: {file.name}")
return {'FINISHED'}
class ImportDXFPanel(Panel):
bl_label = "Import Panel"
bl_idname = "OBJECT_PT_import_dxf"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Import DXF"
def draw(self, context):
layout = self.layout
layout.operator("object.import_dxf", text="Import")
def register():
bpy.utils.register_class(ImportDXF)
bpy.utils.register_class(ImportDXFPanel)
def unregister():
bpy.utils.unregister_class(ImportDXF)
bpy.utils.unregister_class(ImportDXFPanel)
if __name__ == "__main__":
register()
context.wm.fileselect_add
operator which basically opens a modal with some predefined arguments that are hard-coded into the C++/Python API code, as you can see here. $\endgroup$