I would like to read the scene hierarchy of CAD files using Datasmith and Python, before actually importing the CAD file and generating the assets and actors in the level. Until now, I have come up with the following snippet of code to print the names of all mesh actors: (based on the relevant documentation)
import unreal ds_scene = unreal.DatasmithSceneElement.construct_datasmith_scene_from_file(r'C:\Path\To\StepFile.stp') if ds_scene == None: unreal.log_error('Failed to load datasmith scene.') else: for x in ds_scene.get_all_mesh_actors(): print(x.get_label()) ds_scene.destroy_scene()
However, this only yields a list of all mesh actors, whereas I would like to have the hierarchy (in a tree structure) of all actors.
Ideally, I want to get the root actor of the scene and subsequently call
, but not something like
So my question: Is there a way to obtain the hierarchy of the to-be-loaded actors? I thought it should be possible, as Datasmith should have that information internally to create the scene.
Any help would be greatly appreciated.
P.S. I found out that the code above doesn’t work in UE 4.24, but it does work in 4.23. In 4.24, get_all_mesh_actors() just returns an empty list, even if the given filepath is correct. Is this a bug?