Download

Get BPs components by python

Hi! Could anyone help with accessing blueprint components via python? I have a BP with few static meshes inside, and I want to manipulate them (like, copy transformations, remove, rename etc)
I managed to get selected actor in scene, but have no ide how to get deeper.




import unreal as u

blueprint_selected = u.EditorLevelLibrary.get_selected_level_actors()

act=blueprint_selected[0]

cl = u.Blueprint.get_class(act)



Hi Mike.
I’m also new to the python UE API. Not sure this is the best way but I can get to the mesh object like.



import unreal as u
actors = u.EditorLevelLibrary.get_selected_level_actors()
act=actors[0]
scene = act.root_component
print(dir(scene))
childn = scene.get_num_children_components()
print(dir(childn))
child = scene.get_children_components(True)
for each in child:
      oname = str(each.get_fname())
            if 'MESH' in oname.upper():
                  themesh = each

print("Mesh is: ")
print(themesh)


For example inside the for each loop the mesh name will be included in the oputput if you do e.g. ‘name = each.get_full_name()’
Pasting Python in here is awkward … :stuck_out_tongue:

Well, I`m at the same place here, getting name and position of the component is doable, but it looks like add new component to existing BP is not achievable by python. For now it looks like very poor integration into ue api

Not sure.
Its possible creating fresh new BPs using unreal.BlueprintFactory — Unreal Python 4.27 (Experimental) documentation for example
Must see loading the BP and try stuff with AssetToolsHelpers and others
Never tried it for blueprints but achieved creating/editing for Materials
I guess the major issue is the lack of examples, tutorials etc.