How it works internally¶
The following diagram shows how each processes interact to make PyTVPaint work:
sequenceDiagram
participant PyTVPaint
participant TVPaint RPC server
participant TVPaint
PyTVPaint->>TVPaint RPC server: {"jsonrpc": "2.0", "method": "execute_george", "params": ["tv_version"], "id": 45}
TVPaint RPC server->>TVPaint: TVSendCmd(_, "tv_Version", buf)
TVPaint->>TVPaint RPC server: '"TVP Animation 11 Pro" 11.7.1 en'
TVPaint RPC server->>PyTVPaint: {'id': 45, 'jsonrpc': '2.0', 'result': '"TVP Animation 11 Pro" 11.7.1 en'}
- The end user calls
tv_version()
frompytvpaint.george
in Python. - It calls
send_cmd("tv_Version")
which is the low level function that sends george commands - It then calls
rpc_client.execute_remote("execute_george", ["tv_version"])
- The JSON-RPC client sends the serialized JSON payload to the server
self.ws_handle.send(json.dumps(payload))
- The C++ plugin receives the message and store it in the George commands queue.
- George commands are executed in the main thread, so at each plugin tick we check if we have commands to execute, execute them with the C++ SDK function
TVSendCmd
and send back the result. - We get back the result in PyTVPaint and use the
tv_parse_list
function to parse the resulting string from George and return a tuple fromtv_version
.