Download

Blueprint work with python?

Hi there, I dont even know if this is possible, so I am here to find out! And if it is possible, some info on how to :wink:
Is there a way, with python to create nodes and connect them in a blueprints graph using python?
Can you create variables in a blueprint using python?

Basically I have a pretty complex character setup in maya that could be recreated in blueprint, but there would have to be hundreds of nodes built, connected, and fields filled out. This would not only be repetitive but time consuming. In maya I would just run a loop on the data creating the nodes and connecting them.

So, is it possible to create these in blueprint with python?

Well, you actually can use python to script the Unreal Editor: https://docs.unrealengine.com/en-US/…hon/index.html
Though, the API does not seem to be very useful for what you want to do (unless I’m missing something): https://docs.unrealengine.com/en-US/PythonAPI/

But you may know that copying blueprint are actually stringifyed. For example, if you copy some Blueprint nodes, and you paste it into a text editor, you’ll end up with something like that:


Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_2"
NodePosX=1056
NodePosY=704
NodeGuid=C9B9DA7741261731C22962AEEDF6F3A4
CustomProperties Pin (PinId=023CF8024C810D16C9C8C1BEC9C7A63A,PinName="InputPin",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,LinkedTo=(K2Node_Knot_1 E7AC41CE46EC1DE483F7A481581A5703,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=295D141F4591FFA5FBA41C88E2122A8A,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,LinkedTo=(K2Node_DynamicCast_0 3D30A2404F4D1B50A2C005918B90EE8D,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object

So you might be able to generate stringifyed Blueprint that you’ll be able to copy/paste into the editor.
I actually didn’t find any documentation for this, so you may have to reverse engineer it a bit…

Yeah, thats how I do it now. I actually have a bunch of maya python that prints out files that I copy and paste into the BP and it sets it up. That just seems so messy and limited.
I stumbled onto this website that I think explains it well, I am going to give it a shot when I get a chance.

very interesting topic. Could you dive a bit deeper how you implemented the stringifyed Blueprint inside the editor? At the moment I am searching for a way how to get the string into the python generated blueprint.

If youre talking about how I do it. In maya I have a python script that formats the data, so for aim constraints in maya it formats and saves a text file that has the nodes for LookAts and the connections, it just saves that file to disk. Once in the appropriate editor window I just hit ctrl+v and it pastes that text into the editor which converts it into the nodes it describes.