I am currently importing fbx assets without the materials. Using : unreal.StaticMaterial — Unreal Python 4.27 (Experimental) documentation as a reference, I would like to be able to get:
I’m just unsure of where to go once I get a static mesh. My snippet only works in some cases where I imported the materials with the fbx.
editor_util = MyEditorUtility()
for item in editor_util.get_selected_assets():
slotCount=10 # this is arbitrary, I don't know how to get total slots on a static mesh.
for i in range(slotCount):
print 'index: %s slotname: %s' % (i, item.get_material(i).get_name())
Hi @flatKAT ,
I believe what I was doing in a similar situation was to call get_material of the static mesh in a while loop as long as the get_material() returned a material (i.e. not None). This way I was counting the material slots until get_material ()returned None in which case I knew there are no more material slots.
I am not sure if my approach works with fbx that were imported without materials, though.
Out of interest: Could you share the snippet of how you import an fbx without material?
I’ve given up on UE python for now. If you look at AlexQuevillon posts and youtube channel, you will find a snippet to disable the option of importing materials,
To import a mesh without materials you would need to set the import task to not false:
def _generate_fbx_import_task(importFilePath, destination_path, replace_existing=True, importFileName=None,
automated=True, save=True, materials=False):
task.filename = importFilePath
task.destination_path = os.path.dirname(destination_path)
task.destination_name = importFileName
task.replace_existing = replace_existing
task.automated = automated
task.save = save
task.options = ue.FbxImportUI()
task.options.import_materials = False
task.options.import_mesh = mesh
task.options.mesh_type_to_import = ue.FBXImportType.FBXIT_STATIC_MESH
I am using the FbxSceneImportFactory to import an FBX into level and I was wondering if I could disable material import for this approach as well as you showed with yours.
From the docs it looks like it still uses AssetImportTask. So it should work the same, I haven’t explored FbxSceneImportFactory yet though.