Hey,
I started this week with Unreal and Python which opened up a lot of questions. What I basically want to do is checking my scene, getting all tagged SkeletalMeshActors, add them all to a sequence record track and start recording.
The problem is, that I can’t filter for tags. (this are the default component tags right?)
Here is a script that looks for tags on actors. Would that get you started?
retrieves all Actor in levels having the SU.GUID.XXXX tag
level_actors = unreal.EditorLevelLibrary.get_all_level_actors()
guid_actors = {}
for actor in level_actors:
tags = [str(tag) for tag in actor.tags if str(tag).startswith(‘SU.GUID.’)]
if len(tags) > 0:
guid = tags[0][8:]
if not guid in guid_actors:
guid_actors[guid] = ]
guid_actors[guid].append(actor)
Yeah great, I checked everything again and just used the wrong tag section. The tag search thing works now, but do you have a solution for the second problem? Help tells me that on the sequence recorder settings is something like reduce_keys or sequence_length. How do I access them?
I tried things like this:
Hey, it’s hard to tell from those lines of code, but it looks like you’re not calling set_editor_property() on an instance of the SequenceRecorderSettings object.
SequenceRecorderSettings does have editor properties named recording_delay, reduce_keys, and sequence_length, but not sequence_name. Don’t forget to put quotes around the name of the parameter when you call set_editor_property.
Hey thank you! It was a little bit confusing that I have to create an object that handles all the information instead of just write it directly to unreal.
Thank you for you support!
Do you know if it is possible to enter/exit playmode in the editor with a python script? And is it possible to get/set variables in blueprints with python?
Hey, glad you got it working.
That’s a pretty important distinction to keep in mind when you’re working in Python. A lot of the time, you’ll be working with instances of the classes in the Unreal API – like say instances of the unreal.Actor class.
I don’t see any way to launch a Play In Editor session in Python. But you can get/set variables on Blueprint Actors in your Level using the get_editor_property() and set_editor_property() functions – as long as those variables are “public”. That is, as long as the variables have the little eye symbol in the Blueprint editor, so that they show up in the Details panel when you select the Actor in your Level. Like, this works for me:
import unreal
all_actors = unreal.EditorLevelLibrary.get_all_level_actors()
for actor in all_actors:
print actor.get_name()
if not actor.get_name().find("MyActorClass") == -1:
print("property:")
print(actor.get_editor_property("aString"))
Hey there! I actually stumbled upon this thread because I was wondering how to get/set variables on Blueprint actors (thanks a lot for your clear answer, @Ro-Su-!).
However, I think I can also answer this question (…even if I am two years too late:D):
For exiting playmode, I did a little workaround by just calling the console command “Exit”.
Have you ever tried these two commands in a common python file.
For example, we have a test.py file, and two functions are “enterPlaymode” and “exitPlaymode”, the main function has only two lines,
“enterPlaymode()
exitPlaymode”
And then “py test.py” in the python or cmd in UE4 4.26;
I find the exitPlaymode will not work.
Could you give me some suggestions?