Datasmith not importing meshes from Revit in Unreal 5.1.1

Hello. I’m attempting to filter out certain kinds of Revit categories when importing a scene with Datasmith. I’m following the quite-nice instructions at Customizing the Datasmith Import Process in Unreal Engine | Unreal Engine 5.0 Documentation. (Caveat: I’ve never done this before.)

Here is my script:

import unreal

ds_file_on_disk = "C:\\Users\\coryb\\Documents\\Unreal Projects\\Ingestor\\DatasmithFiles\\racbasicsampleproject-3DView-From_Yard.udatasmith"

ds_scene_in_memory = unreal.DatasmithSceneElement.construct_datasmith_scene_from_file(ds_file_on_disk)

mesh_actors = ds_scene_in_memory.get_all_mesh_actors()
print("Num mesh_actors:")
print(len(mesh_actors))

The output is 0 meshes. I’ve tried with two datasmith files from two different Revit projects. One of these projects is the canonical example “rac_basic_sample_project.rvt” file.

Both Datasmith files work great when I use the UI “Datasmith → File Import…”

Win 10, Unreal 5.1.1-23901901+++UE5+Release-5.1, Revit exporter version “Last updated 2/7/2023”

Between the construct_datasmith_scene_from_file and the get_all_mesh_actors() do a
ds_scene_in_memory.translate_scene()

Excellent, that worked. Thank you for the quick, accurate help.

Perhaps I missed this when running the script previous, but at present the call to translate_scene() files off long list of “LogDatasmith: Warning: Missing actor referenced in metadata” errors. Should this be of concern?

image

I think those warnings do matter. In this script, if I uncomment the call to translate_scene, then Unreal will invariably crash:

import unreal
ds_file_on_disk = "E:\\Projects\\UrsaLeo\\RevitIngestor\\DataSmithFiles\\racbasicsampleproject-3DView-Approach.udatasmith"
ds_scene_in_memory = unreal.DatasmithSceneElement.construct_datasmith_scene_from_file(ds_file_on_disk)
#ds_scene_in_memory.translate_scene()
mesh_actors = ds_scene_in_memory.get_all_mesh_actors()
key_name = "name"
objects_and_values = ds_scene_in_memory.get_all_objects_and_values_for_key(key_name, unreal.DatasmithMeshActorElement)

I don’t think the example usage script to obtain metadata on this page is working in Unreal 5.1: Using Datasmith Metadata in Unreal Engine | Unreal Engine 5.1 Documentation

I did some tests on 5.1.1 and it is working for me.
No crash and I get some objects from the get_all_objects_and_values_for_key function.

What is your log file of the crash, can you share your udatasmith file and attached udsmesh.

import unreal

ds_file_on_disk = "D:\\projectPS\\Data\\Udatasmith\\rac_basic_sample_project-3DView-{3D}.udatasmith"
ds_scene_in_memory = unreal.DatasmithSceneElement.construct_datasmith_scene_from_file(ds_file_on_disk)
ds_scene_in_memory.translate_scene()
mesh_actors = ds_scene_in_memory.get_all_mesh_actors()

#print("## meshs actors labels")
#for a in mesh_actors:
#    print(a.get_label())

key_name = "Element_Type"

print("## metadata strings")
does,strings = ds_scene_in_memory.get_all_objects_and_values_for_key(key_name, unreal.DatasmithMeshActorElement)
for s in strings:
    print(s)

I did some tests on 5.1.1 and it is working for me.

Interesting. I’ve tried it across two projects and still get a crash 100% of the time. I’m now running your script directly (except of course for the path to the .udatasmith file).

What is your log file of the crash

I’ve attached it here: Test20230313.log (323.0 KB)

can you share your udatasmith file and attached udsmesh

No problem: racbasicsampleproject-3DView-Approach_DataSmithFiles.zip (10.6 MB)

The in-editor summary does show that an assertion fails at line 1082 of SharedPointer.h:

Assertion failed: IsValid() [File:D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Templates\SharedPointer.h] [Line: 1082]

Thanks a ton for the assistance.

I could reproduce. I will create a ticket as it should not crash, thank you for reporting.
Will also see if someone as an idea what could make the export not to be so complete.

Thanks!

If relevant, I don’t think I mentioned that I created the .udatasmith file with Revit 2023.

Thank you, I saw that information in the .udatasmith file.