Announcement

Collapse
No announcement yet.

confusing Python stuff

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

    confusing Python stuff

    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?)

    all_actors = unreal.EditorLevelLibrary.get_all_level_actors()

    skeletal_actors = unreal.EditorFilterLibrary.by_class(all_actors, unreal.SkeletalMeshActor)

    tagged_actors = unreal.EditorFilterLibrary.by_actor_tag(skeletal_actors, "TestTag", unreal.EditorScriptingStringMatchType.MATCHES_WILDCARD)


    Also if I want to access the sequence recorder properties, it occurs an error that they do not exist (help says they exist^^).

    unreal.SequenceRecorderSettings.set_editor_property(sequence_name, 'RecordedSequence')

    Am I doing something wrong or are some functions not properly adapted to Python?

    Best regards

    #2
    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)
    Last edited by pf_breton; 07-13-2018, 02:09 PM.
    Pierre-Felix Breton

    Sr Technical Product Designer AEC, Unreal Engine
    Epic Games - LinkedIn

    Comment


      #3
      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:

      unreal.SequenceRecorderSettings.set_editor_property(sequence_name, 'RecordedSequence')

      or

      unreal.SequenceRecorderSettings.sequence_name = 'RecordedSequence'

      but both seams to be not the right way ('SequenceRecorderSettings' has no attribute 'recording_delay')

      Also is it possible to start or stop the editor with a script?

      Best regards
      Last edited by Elias Kremer; 07-16-2018, 08:46 AM.

      Comment


        #4
        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.

        For example:

        my_settings_object.set_editor_property("recording_delay", 5)

        or

        unreal.SequenceRecorderSettings.set_editor_property(my_settings_object, "recording_delay", 5)



        Comment


          #5
          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?
          Last edited by Elias Kremer; 07-17-2018, 03:46 AM.

          Comment


            #6
            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:

            Code:
            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"))

            Comment

            Working...
            X