Open sinokgr opened 7 years ago
Hi @sinokgr, currently you should use the ad-hoc method .asset_import_data() that returns a list of dictionaries containing file infos. SourceFilePath is empty because in recent UE4 versions multiple source files can be mapped to the same asset (this is why .asset_import_data() returns a list)
awesome! thanks! :)
Sorry that I had to reopen this, but I think that something is not working as expected. my FBX is in D:\Scraps\Unreal\TestProject\Revit\SmallProject\FBX_4.fbx (where TestProject is the project directory)
The asset_import_data() returns:
{
'timestamp': 1493894320L,
'absolute_filepath': u'C:/Program Files (x86)/Epic Games/4.13/Revit/SmallProject/FBX_4.fbx',
'relative_filepath': u'../../../Revit/SmallProject/FBX_4.fbx',
'filehash': u'149121516f64e5c954461a7d465437fc'
}
So, the absolute path is wrong, and when I tried to convert the relative to absolute using the ue.convert_relative_path_to_full() I got the exact same wrong absolute path. Does this has to do with where the project is located?
It looks like the absolute_filepath build procedure is wrong:
i do not think we should expose an absolute_filepath but let the user to rebuild it from the current working directory. Something like
import os
os.path.join(os.getcwd(), item['relative_filepath'])
Does it work in this way ?
Not really, this returns C:\Program Files (x86)\Epic Games\4.13\Engine\Binaries\Win64../../../Revit/SmallProject/FBX_4.fbx
my workaround for now is the following:
import unreal_engine as ue
import os
def get_static_mesh_absolute_path(static_mesh):
return_list = []
asset_import_data = static_mesh.asset_import_data()
# the real asset path from the asset (replace the /game/ with actual content path)
asset_dir = ue.get_content_dir() + os.path.os.path.dirname(static_mesh.get_path_name())[6:]
# loop for all
for a in range(0, len(asset_import_data)):
# copy asset dir
current_asset_dir = asset_dir
# find relative path
fbx_relative_dir = asset_import_data[a].get('relative_filepath')
# calculate the relative dir depth
steps = len(fbx_relative_dir.split("..")[:-1])
# remove the last x depths from the current asset dir
for i in range(0, steps):
current_asset_dir = os.path.dirname(current_asset_dir)
# combine and append the absolute path in the list
return_list.append(current_asset_dir + fbx_relative_dir.split("..")[steps:][0])
# return the paths
return return_list
If you find a better approach I'm all ears cause this code works but doesn't look clean.
Cheers, Nick
Hi guys, I've been away for a while and I was so glad to see how much progress you've all done. Huge congrats to all. The builds are so useful, many thanks for that. 👍
Now, to my problem. I'm trying to retrieve the SourceFilePath from the assets.![image](https://cloud.githubusercontent.com/assets/22396951/25694982/24521872-30a9-11e7-99c2-3c63db61d4b9.png)
I tried to check both asset's properties and asset.AssetImportData's properties and they both come empty. Any ideas why?
Thanks, Nick