x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to use python in Editor to build lighting and package project?

Is it even possible?

I'm trying to look into the concept of using Python in editor to create levels, setup assets, build lights, and finally build the package. (Looking for quick turnaround from customer assets to final playable result).

From my research and experimentation so far I know we can create levels and populate it with assets, but I seem unable to find the correct API calls to start the light-bake processes or the packaging processes. I'm finding python classes to make LightingBuild settings, and ProjectPackaging settings, but nothing to actually start the process.

What are my options here, or can you help point me in the correct direction? Any help would be greatly appreciated, thanks.

Link to Python API for reference: https://api.unrealengine.com/INT/PythonAPI/index.html

Product Version: UE 4.21
Tags:
more ▼

asked Feb 21 '19 at 10:44 AM in Using UE4

avatar image

Weibye
280 1 8 5

avatar image Weibye Feb 22 '19 at 02:41 PM

Still need answer and assistance, but will provide update on current research, in the event someone else is looking to solve the same issues. Figured out how to call C++ code from a python script from this very helpful video. Not at all complicated as everything (may be some exceptions) exposed to Blueprints will also be exposed to Python.

PythonFunctions.h:

 #pragma once
 
 #include "CoreMinimal.h"
 #include "Kismet/BlueprintFunctionLibrary.h"
 #include "PythonFunctions.generated.h"
 
 UCLASS()
 class PYTHONPROJECT_API UPythonFunctions : public UBlueprintFunctionLibrary
 {
     GENERATED_BODY()
 
 public:
     UFUNCTION(BlueprintCallable)
     static void CalledFromPython(FString InputString);
     
 };

PythonFunctions.cpp:

 #include "../Public/PythonFunctions.h"
 
 void UPythonFunctions::CalledFromPython(FString InputString)
 {
     UE_LOG(LogTemp, Error, TEXT("%s"), *InputString);
 }

Python script:

 import unreal
 unreal.PythonFunctions.called_from_python("Hello world")

Console output:

 LogPython: unreal.PythonFunctions.called_from_python("Hello world")
 LogTemp: Error: Hello world

(Exactly as expected)

Things to note: Functions declared in PascalCase in C++ will be converted to snake_case within the unreal python module.

Further research: To be able to call the build lighting commands, or the package project commands, it seems I either will need to go into the engine and expose that code to Blueprints/Python, or write some custom C++ code (Plugin perhaps) to call it for me.

avatar image StefanKubicek Mar 17 '19 at 03:09 AM

I'm looking for an answer to this as well. We need to build multiple lighting scenarios per map, having the option to automate that via Python would be very helpful.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question