I know it is possible to get the Skeleton asset used in the Skeletal Mesh asset using unreal.SkeletalMesh.skeleton
unreal.SkeletalMesh — Unreal Python 5.0 (Experimental) documentation
How about in-reverse?
I know it is possible to get the Skeleton asset used in the Skeletal Mesh asset using unreal.SkeletalMesh.skeleton
unreal.SkeletalMesh — Unreal Python 5.0 (Experimental) documentation
How about in-reverse?
The solution just crossed my mind is…
get all skeletal meshes and check if there is any skeletal mesh using the input skeleton.
( use list & for loop)
But I don’t know if this is an efficient way.
I hope this helps you
Guess that might be the only way? also that implies skeletal mesh and skeleton are not 1 to 1 relationship: a skeletal mesh can only have one input skeleton, but a skeleton can be used on multiple skeletal mesh, thus have different preview skeletal mesh?
I have another idea to get skeletal meshes from the skeleton asset.
There is a classmethod called find_package_referencers_for_asset
in Unreal Python.
For example,
import unreal
skeleton_path = "/Game/Characters/Mannequin_UE4/Meshes/SK_Mannequin_Skeleton"
assets = unreal.EditorAssetLibrary.find_package_referencers_for_asset(skeleton_path, False)
skeletal_meshes = []
for asset in assets:
assetData = unreal.EditorAssetLibrary().find_asset_data(asset)
if assetData.asset_class == "SkeletalMesh":
skeletal_meshes.append(asset)
Through this code, it is possible to get a list of skeletal meshes using the skeleton.
(but I don’t know how to get the preview skeletal mesh yet)
I like this one better, I’ll mark this as the solution. Thanks
Thank you, this was very helpful
This is an update to use this in version 5.2
import unreal
skeleton_path = "/Game/Characters/Mannequin_UE4/Meshes/SK_Mannequin_Skeleton"
assets = unreal.EditorAssetLibrary.find_package_referencers_for_asset(skeleton_path, False)
skeletal_meshes = []
asset_lib = unreal.EditorAssetLibrary()
for asset in assets:
check = asset_lib.does_asset_exist(asset)
if not check:
# had a bug where some assets were not in the asset registry?
continue
assetData = asset_lib.find_asset_data(asset)
if assetData.asset_class_path.asset_name == 'SkeletalMesh':
skeletal_meshes.append(asset)