Skip to content

Instantly share code, notes, and snippets.

@nekochanfood
Created October 28, 2022 12:09
Show Gist options
  • Save nekochanfood/28380a23e180a1376d32918372cdedc7 to your computer and use it in GitHub Desktop.
Save nekochanfood/28380a23e180a1376d32918372cdedc7 to your computer and use it in GitHub Desktop.
Display Blender rendering progress in VRChat's Chatbox using OSC
import bpy
import pythonosc
import argparse
from pythonosc import udp_client
from bpy.app.handlers import persistent
client = udp_client.SimpleUDPClient("127.0.0.1", 9000)
def send(message):
# print("successfully send message at" + datetime.datetime.now().strftime(" %Y-%m-%d %H:%M:%S") + ".")
client.send_message("/chatbox/input",[str(message),True])
@persistent
def complete(scene):
m = "Complete!"
send(m)
@persistent
def sendosc(scene):
m = "Rendering..." + " " + str(bpy.context.scene.frame_current)+ "/" + str(bpy.context.scene.frame_end)
if bpy.context.scene.frame_current % 10 == 0: #毎フレームごとやると送信できなくなるので10フレームおきに送信
send(m)
bpy.app.handlers.render_post.append(sendosc)
bpy.app.handlers.render_complete.append(complete)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment