![]() """ Import an STL and do things with it""" # This class is the same as the above class, except it makes these things ![]() # The invoke function calls context.window_manager.fileselect_add # It adds a StringProperty named 'filepath' # Here's what the ImportHelper class does as a mix-in: ![]() The ImportHelper class is not well documented, so I wrote this example to help explain it: #. # Register and add to the "file selector" menu (required to use F3 search "Text Import Operator" for quick access).īpy.types.TOPBAR_MT_file_import.append(menu_func_import)īpy.utils.unregister_class(ImportSomeData)īpy.types.TOPBAR_MT_file_import.remove(menu_func_import)īpy.ops.import_test.some_data('INVOKE_DEFAULT') (ImportSomeData.bl_idname, text="Text Import Operator") # Only needed if you want to add into a dynamic menu. Return read_some_data(context, self.filepath, e_setting) ('OPT_B', "Second Option", "Description two"), ('OPT_A', "First Option", "Description one"), # to the class instance from the operator settings before calling. # List of operator properties, the attributes will be assigned Maxlen=255, # Max internal buffer length, longer would be clamped. """This appears in the tooltip of the operator and in the generated docs"""īl_idname = "import_test.some_data" # important since its how _test.some_data is constructed # invoke() function which calls the file selector.įrom bpy_extras.io_utils import ImportHelperįrom bpy.props import StringProperty, BoolProperty, EnumPropertyĬlass ImportSomeData(Operator, ImportHelper): # ImportHelper is a helper class, defines filename and Where would I start inputting my code to utilize the files I selected and what here is unnecessary noise? import bpyĭef read_some_data(context, filepath, use_some_setting):į = open(filepath, 'r', encoding='utf-8') Could anyone help me make sense of the import file template that Blender 3.2 gives for Python scripting? It seems a lot of this code is unnecessary for the function of opening a dialog box and selecting images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |