To create material
import unreal
tools = unreal.AssetToolsHelpers.get_asset_tools()
matLibrary = unreal.MaterialEditingLibrary()
mat = tools.create_asset("asset_name", "/Game/Gen/", unreal.Material, unreal.MaterialFactoryNew())
baseCol = matLibrary.create_material_expression(mat, unreal.MaterialExpressionConstant3Vector, -180,200)
matLibrary.connect_material_property(baseCol, "", unreal.MaterialProperty.MP_BASE_COLOR)
ImportGroomNoPopUp
import unreal
def get_groom_import_options():
options = unreal.GroomImportOptions()
import_data = unreal.GroomConversionSettings()
# import values
import_data.set_editor_property('rotation', unreal.Vector(90.0, 0.0, 0.0))
import_data.set_editor_property('scale', unreal.Vector(1.0, -1.0, 1.0))
options.conversion_settings = import_data
return options
def get_import_task(file_path, destination_path):
import_task = unreal.AssetImportTask()
import_task.set_editor_property('filename', file_path)
import_task.set_editor_property('destination_path', destination_path)
import_task.set_editor_property('replace_existing', True)
import_task.set_editor_property('replace_existing_settings', True)
import_task.set_editor_property('automated', True)
return import_task
def import_asset(file_path, destination_path):
import_task = get_import_task(file_path, destination_path)
import_task.options = get_groom_import_options()
# run the import task
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([import_task])
import_asset(r"D:/myDocuments/maya/projects/Groom_Gen_Tests/unrealExchange/ZannyGroom_01_Copy2.abc", '/Game/Imports/TestImport/')
Running Python headless in Unreal Engine 5
#Setup variables
$engine = "C:\Program Files\Epic Games\UE_5.X\Engine\Binaries\Win64\UnrealEditor-Cmd.exe"
$project = "C:\MyFolder\MyProject.uproject"
$script = "C:\MyFolder\MyScript.py"
#Start headless editor with specified script. Backtick ` used to preserve quotes in argument list.
Start-Process $engine -ArgumentList "`"$project`" -run=pythonscript -script=`"$script`""