Source code for cgl.plugins.unreal.cli.organize_scene
import sys
[docs]
def organize_scene(action=None):
"""
Organizes the currently opened scene into MDL, LIGHT, and CAMERA folders based off the actors class
Args:
action: Action flag to be used with the fg/bg tool (FG, MG, BG, or Remove)
"""
import unreal
accept_ = ["FG", "MG", "BG", "Remove"]
special_ = ["AtmosphericFog", "BP_Sky_Sphere_C"]
if not action:
static_mesh_actor_list = unreal.EditorLevelLibrary.get_all_level_actors()
action_folder = ""
else:
static_mesh_actor_list = unreal.EditorLevelLibrary.get_selected_level_actors()
action_folder = "{}/".format(action)
for mesh_actor in static_mesh_actor_list:
if action == "Remove":
mesh_actor.set_folder_path("")
else:
if mesh_actor.get_class().get_name() == "StaticMeshActor":
class_ = "MDL"
elif "light" in mesh_actor.get_class().get_name().lower() or mesh_actor.get_class().get_name() in special_:
class_ = "LIGHT"
elif "camera" in mesh_actor.get_class().get_name().lower():
class_ = "CAMERA"
else:
class_ = ""
folder_string = "{}{}".format(action_folder, class_)
mesh_actor.set_folder_path(folder_string)
if __name__ == "__main__":
organize_scene(sys.argv[1])