TypeError: Actor: Failed to convert parameter 'socket_name' when calling function 'Actor.K2_AttachToActor' on 'BP_Camera_C_5'

Hallo
I am trying to attach an actor on another actor and getting an error. I have two actors spawned in the world and trying to attach to another one.

Here I getting the main actor(actor A) from the world

level_actors = unreal.EditorLevelLibrary.get_all_level_actors()
filtered_list = unreal.EditorFilterLibrary.by_actor_tag(level_actors, Car_tag, filter_type=unreal.EditorScriptingFilterType.INCLUDE)
    actor = filtered_list[0]

Now setting the location and rotation and spawn another actor (actor B) in the world.

pos = unreal.Vector(0,0,0)
rot = unreal.Rotator(0,0,0)
ac = unreal.EditorAssetLibrary.load_blueprint_class('/Game/Resim/Blueprints/BP_Camera.BP_Camera')
ac_pos = unreal.EditorLevelLibrary.spawn_actor_from_object(ac, cam_location)

Now trying to attach actor B to actor A using the attach_to_actor command:

ac_pos.attach_to_actor(actor, None, pos, rot, None, None)

and now I am getting the following error

LogPython: Error: ac_pos.attach_to_actor(actor, None, pos, rot, None, None)
LogPython: Error: TypeError: Actor: Failed to convert parameter ‘socket_name’ when calling function ‘Actor.K2_AttachToActor’ on ‘BP_Camera_C_5’
LogPython: Error: TypeError: NativizeProperty: Cannot nativize ‘NoneType’ as ‘SocketName’ (NameProperty)
LogPython: Error: TypeError: Nativize: Cannot nativize ‘NoneType’ as ‘Name’

what may be the cause ?

Hi ronyshaji1, try swapping the None for " " in the attach_to_actor.

Second parameter is supposed to be a name and python api doesn’t seem to be able to auto-convert from None, so try using "" or unreal.Name() instead.

1 Like

Thanks for the reply. I got the answer