Announcement

Collapse
No announcement yet.

Problems with iterating over components and using set_editor_property

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Problems with iterating over components and using set_editor_property

    Hi,

    I am trying to add a tag to SceneComponents with a Script.

    Code:
    import unreal
    
    actors = unreal.EditorLevelLibrary.get_selected_level_actors() 
    sceneComponents = actors[0].get_components_by_class(unreal.SceneComponent)
    for sceneComponent in sceneComponents:
        name = sceneComponent.get_name()
        print name
        if name.find("@") != -1:
            tag = name.split("@")[1]
            a = unreal.Array(unreal.Name)
            a.insert(0,tag)
            sceneComponent.set_editor_property("component_tags", a)
    This works for the first SceneComponent, after that, the whole SceneComponents List seems to be destroyed by the garbage collector...
    As you can see at the print out of the name....

    So is it not possible to iterate over a list of components and use set_editor_property???


    Code:
    LogPython: DefaultSceneRoot1
    LogPython: BillboardComponent_40
    LogPython: W672699_H00_GMFuellung_normal_stp
    LogPython: W672699_H00
    LogPython: W676988_01_Bediengehaeuse_zurGMConfecPROOSu_Mo__701092500_1
    LogPython: W381961_H00_W381961_H00_1_mesh
    LogPython: W679288_00_Distanzstueck_zumBediengehaeuseGMConfecPRO_5_mesh
    LogPython: W679286_00_Halteblech_zuBediengehaeuseGMConfecPRO_1
    LogPython: W107084_00_6KT_Schraube_M8X20A2_3_mesh
    LogPython: R146927_00_6KT_Schraube_M8X30A2_4_mesh
    LogPython: W108633_A00_W108633_A00_4@wasser
    LogPython: TRASH_StaticMeshComponent_2055
    LogPython: TRASH_StaticMeshComponent_2047
    LogPython: TRASH_SceneComponent_2069
    LogPython: TRASH_SceneComponent_2071
    LogPython: TRASH_StaticMeshComponent_2041
    LogPython: TRASH_StaticMeshComponent_2045
    LogPython: TRASH_SceneComponent_2064
    LogPython: TRASH_SceneComponent_2079
    LogPython: TRASH_SceneComponent_2074
    LogPython: TRASH_SceneComponent_2065
    LogPython: TRASH_StaticMeshComponent_2040
    LogPython: TRASH_StaticMeshComponent_2054
    LogPython: TRASH_StaticMeshComponent_2048
    LogPython: TRASH_StaticMeshComponent_2057
    LogPython: TRASH_SceneComponent_2067
    LogPython: TRASH_SceneComponent_2072
    LogPython: TRASH_StaticMeshComponent_2058
    LogPython: TRASH_SceneComponent_2081
    LogPython: TRASH_StaticMeshComponent_2051
    LogPython: TRASH_SceneComponent_2073
    LogPython: TRASH_StaticMeshComponent_2052
    LogPython: TRASH_StaticMeshComponent_2061
    LogPython: TRASH_SceneComponent_2077
    LogPython: TRASH_StaticMeshComponent_2062
    LogPython: TRASH_SceneComponent_2070
    LogPython: TRASH_SceneComponent_2075
    LogPython: TRASH_SceneComponent_2066
    LogPython: TRASH_StaticMeshComponent_2059
    LogPython: TRASH_SceneComponent_2078
    LogPython: TRASH_SceneComponent_2082
    LogPython: TRASH_StaticMeshComponent_2053
    LogPython: TRASH_SceneComponent_2080
    LogPython: TRASH_SceneComponent_2068
    LogPython: TRASH_StaticMeshComponent_2049
    LogPython: TRASH_StaticMeshComponent_2044
    LogPython: TRASH_StaticMeshComponent_2043
    LogPython: TRASH_SceneComponent_2085
    LogPython: TRASH_SceneComponent_2084
    LogPython: TRASH_StaticMeshComponent_2042
    LogPython: TRASH_SceneComponent_2083

    #2
    This works... But according to the documentation set_editor_property is rather recommended:

    Code:
            sceneComponent.component_tags = a
            #sceneComponent.set_editor_property("component_tags", a)

    Comment


      #3
      This is not what you are looking for, but i had a similar situation and ended up using the "actor" tags
      Code:
      meshActor = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.StaticMeshActor, [0,0,0], rotation=[0,0,0])
      meshActor.tags = ["words","2","foo bar"]
      print(meshActor.tags)
      print(meshActor.tags[1])

      Comment

      Working...
      X