No announcement yet.

How to read hierarchy of CAD file before import

  • Filter
  • Time
  • Show
Clear All
new posts

    How to read hierarchy of CAD file before import

    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.')
        for x in ds_scene.get_all_mesh_actors():
    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 actor.get_children() on that actor to get a tree of all actors.
    However, the documentation of DatasmithSceneElementBase only mentions the following functions: get_all_mesh_actors(), get_all_camera_actors() and get_all_light_actors(), but not something like get_all_actors() or get_root_actor().

    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?