As you can see from the output log, the variable that created inside interchange blueprint pipeline base class wont accessible from python side.
wondering if it’s a bug or something else.
[Image Removed]
As you can see from the output log, the variable that created inside interchange blueprint pipeline base class wont accessible from python side.
wondering if it’s a bug or something else.
[Image Removed]
Steps to Reproduce
LogPython: import unreal
sel_asset = unreal.EditorUtilityLibrary.get_selected_assets()[0]
AssetSubsystem = unreal.get_editor_subsystem(unreal.EditorAssetSubsystem)
pipeline_instance = AssetSubsystem.load_asset(sel_asset.get_path_name())
bp_pipeline_var = pipeline_instance.get_editor_property("custom_var")
print(f"BP Pipeline Variable: {bp_pipeline_var}")
Hi Wei,
Your issue can be reproduced with other types of blueprints.
Not being an expert on blueprints, I am passing your findings to the team who could help you.
Regards,
Jean-Luc
Hey Wei Zeng, your snippet doesn’t work because AssetSubsystem.load_asset returns the UBlueprint* rather than the class default object (CDO) that stores the asset’s default property values. Here is the distinction:
Here is your snippet but modified to get the custom_var value from the asset’s CDO instead:
import unreal
sel_asset = unreal.EditorUtilityLibrary.get_selected_assets()[0] # Get selected asset
bpgc = unreal.EditorAssetLibrary.load_blueprint_class(sel_asset.get_path_name()) # Loads the selected asset's BlueprintGeneratedClass (BPGC)
cdo = unreal.get_default_object(bpgc) # Gets the class default object (CDO) from the BPGC
custom_var = cdo.get_editor_property("custom_var") # Retrieve property value from the CDO
If you need more help do let us know.
You can indeed instantiate the BPGC in memory that way. That’s permitted for any use case for which you’d use NewObject in C++, so if you want to instantiate it to set some parameters and call some (CallInEditor) functions, that works. It won’t create an asset. If you want to call member functions that are only defined in blueprint, use call_method:
obj_new = unreal.new_object(bpgc)
obj_new.call_method("TestFunc1")
obj_new.call_method("TestFunc2", parameters)
Objects created in Python behave like any UObject memory wise. If you don’t leak any reference to the object, it will be cleaned up on next garbage collection pass. You can verify this by running obj refs to check referencers and obj gc to trigger a garbage collection pass in console like this:
Python: print the path name
obj_new = unreal.new_object(bpgc)
print(obj_new.get_path_name())
UE console, check that it’s cleaned up:
LogPython: /Engine/Transient.EUW_Test_C_1
Cmd: obj refs name=/Engine/Transient.EUW_Test_C_1
LogReferenceChain: EUW_Test_C /Engine/Transient.EUW_Test_C_1 is not currently reachable.
Cmd: obj gc
Collecting garbage and resetting GC timer.
Cmd: obj refs name=/Engine/Transient.EUW_Test_C_1
LogObj: Couldn't find object.
Thanks for the help Zhi Kang!
Glad to help!
Thanks a lot! This works!
On the other hand, I am wondering after loaded the bpgc, can i create a instance in the memory like this? Do I need to manage this instnace to free up the memory or does unreal editor will clear up automatically?
import unreal
sel_asset = unreal.EditorUtilityLibrary.get_selected_assets()[0]
bpgc = unreal.EditorAssetLibrary.load_blueprint_class(sel_asset.get_path_name())
new_instance_in_memory = unreal.new_object(bpgc)