bl_info = {
“name”: “Custum addon”,
“author”: “Yuan”,
“version”: (1,0),
“blender”: (4,0,1),
“location”: “View3D”,
“description”: “import things”,
“warning”: “”,
“doc_url”: “”,
“category”: “Import”,
}
import bpy
import os
def importFbx(meshesPath, context):
if not meshesPath:
self.report({'ERROR'}, "No directory selected.")
return {'CANCELLED'}
for fileName in os.listdir(meshesPath): # Iterate through files in the directory
if fileName.lower().endswith('.fbx'):
full_path = os.path.join(meshesPath, fileName)
bpy.ops.import_scene.fbx(filepath=full_path)
return {'FINISHED'}
class IMPORT_OT_import_fbx(bpy.types.Operator):
bl_idname = “import_scene.fbx”
bl_label = “Importer des objets”
def execute(self, context):
meshesPath = bpy.context.scene.fbx_directory # Get the directory path
return importFbx(meshesPath, context)
class VIEW3D_PT_my_Panel(bpy.types.Panel):
bl_idname = “VIEW3D_PT_my_panel”
bl_label = “Import Objects”
bl_space_type = “VIEW_3D”
bl_region_type = “UI”
bl_category = “Import-Export”
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(context.scene, "fbx_directory", text="FBX Directory")
row.operator("import_scene.fbx", text="Import", icon='IMPORT')
row = layout.row()
row.operator("wm.redraw_all", text="Refresh", icon='FILE_REFRESH')
def register():
bpy.utils.register_class(IMPORT_OT_import_fbx)
bpy.utils.register_class(VIEW3D_PT_my_Panel)
bpy.types.Scene.fbx_directory = bpy.props.StringProperty(subtype=“DIR_PATH”) Property to store the directory
def unregister():
bpy.utils.unregister_class(IMPORT_OT_import_fbx)
bpy.utils.unregister_class(VIEW3D_PT_my_Panel)
del bpy.types.Scene.fbx_directory
if name == “main”:
register()
Here is the script for an add-on to import fbx… and blender says :
Python: Traceback (most recent call last):
File “\addon_import.py”, line 37, in execute
File “\addon_import.py”, line 25, in importFbx
if fileName.lower().endswith(‘.fbx’):
File “D:\blender_4.0\4.0\scripts\modules\bpy\ops.py”, line 109, in call
ret = _op_call(self.idname_py(), kw)
TypeError: Converting py args to operator properties: : keyword “filepath” unrecognized
witch is weird because it’s the first argument for bpy.ops.import_scene.fbx, can someone help me ?