Add components to a Blueprint asset created in python using a BlueprintFactory

Hey all,

I’m trying to write an automation script for importing FBXs into the editor, and creating a blueprint with skeletal and static mesh components for each static and skeletal mesh imported. Everything works in regards to importing the meshes, materials, and textures into the correct locations, but after creating a blueprint using a BlueprintFactory, I run into issues adding components. I’m currently creating the blueprint via:

blueprint_name = "BP_" + str(destination_name)
package_path = task.destination_path
factory = unreal.BlueprintFactory()
factory.set_editor_property("ParentClass", unreal.Actor)
new_blueprint = unreal.AssetToolsHelpers.get_asset_tools().create_asset(blueprint_name, package_path, None, factory)
unreal.EditorAssetLibrary.save_loaded_asset(new_blueprint)

But any component I instantiate afterwards is transitory even if I set the “outer” parameter to the generated blueprint object:

skeltal_mesh_component = unreal.SkeletalMeshComponent(bp_class, 'DoesNotWork')
skeltal_mesh_component.attach_to_component(bp_class.root_component, ' ', unreal.AttachmentRule.KEEP_WORLD, unreal.AttachmentRule.KEEP_WORLD, unreal.AttachmentRule.KEEP_WORLD, False)

It will add the component to the blueprint, but they seem to be transitory since they aren’t editable, and any time you modify the blueprint they’ll disappear.

Do you need to create a custom Factory to add components when creating a blueprint, or am I going about the whole process backwards? I was thinking of seeing if there was a way to wrap SSCSEditor functions into python, but if that’s the case, I’d probably just forgo python altogether and just wright it as a separate c++ plugin.

Thanks for the help

I’m with the same problem right now, someone can help?