Looking for help with an open source project

I’m creating an open source application for managing 3D part libraries and am looking for help.

I’m mainly a .Net developer and I’ve been able to draft a live link plugin for blender but I’m not familiar enough with Python and the Blender API to get it working but I’ve commented the steps that need to be taken.

All the live link plugin needs to do is:

  1. Listen to the local port for a json formatted file path.
  2. Import the .obj (always is just a .obj, no textures)
  3. convert faces to quads and get seams from UV islands.

[Edit: 2 & 3 are implemented but need to be tested. #1 now is a asyncio server that I have no idea how to start when blender is launched or the addon is enabled. It appears not to run.]

If anyone wants to help you can contribute to the plugin on github:

Bump, still looking for help. I can’t find anyone up to this simple task on freelance sites. Where is the best place to hire a dev for a day?

bpy.utils.register_class() is for classes that inherit from a blender-defined class (panels, operators, gizmos, etc). You don’t need to use it on your run-of-the-mill python classes.

I get errors if I remove the Register functions so am I required to just have empty functions for register and unregister in there if I’m not extending blender classes?

I have sat down and figured out what I needed to fix but now I’m at the point where I need to have my code start and run in the background when blender starts or from when the addon is loaded or whatever. How can I do that?

And also if I try and remove the register and unregister functions I get errors when enabling the addon. If I leave them blank python expects an indented line. so idk how to get rid of the unnecessary class extension.

Here is my updated script: https://github.com/kitbashery/Kitbashery/blob/Latest-Experimental/Assets/StreamingAssets/LiveLinkPlugins/KitbasheryBlenderLiveLink.py

I’ll have a proper look at this tomorrow,

however for having code run in the background, you use a handler. I see you went down that route already having it commented out. What didn’t work there?
And you need the register and unregister functions for blender to enable the addon. So if you remove them you’d obviously get errors.

I just fixed the handler but the server doesn’t appear to start. I’m really just brute force trying things at this point lol.

Your best bet here is to look at how the BlenderKit add-on handles this. It’s bundled with Blender and the comments are decent. No point in trying to brute force a solved problem.

I took a look at it and it kinda looks like it is using some kind of built in threading on a timer, but there is a ton of code there and I’m to new to python to really understand what is going on. Maybe the tasks_queue.py is doing what I want but is way overkill for what I need. idk

I didn’t know the BlenderKit addon existed. Pretty neat
So in register a function is called that in turn registers a timer for certain submodules.

def register():
    .
    .
    .
    if user_preferences.use_timers:
        bpy.app.timers.register(check_timers_timer, persistent=True)

The check_timers_timer function just regularly checks if all the timers the addon needs exist and if not creates them.
For example this line registers the function timer_update from the file search.py

if not bpy.app.timers.is_registered(search.timer_update):
    bpy.app.timers.register(search.timer_update)

Important to understand that the timer_update returns a float which tells blender to wait the returned amount before it’s called again
more info on timers here

hope that helps

Well the thing with timers is if I have them check the local port for data every X seconds then what if the user presses the “send to blender” button when blender is not checking. I’m not continuously streaming data and the user isn’t importing from blender like in BlenderKit but sending a file path to blender.

I could have the timer start the server after X seconds after startup then disable the timer I guess. Is there really no way to just call a function that is in a class from the register function after registering the class?

Buffered I/O ?

********* some extra characters for the spambot ***********

idk, to clarify the “send to blender” button is in another application blender has no knowledge of.

So I gave timers a go and I tried running the async start server function after 5 seconds.

async def startServer():

`print("Initialized Kitbashery live link... listening...")    
server = await asyncio.start_server(listen, 'localhost', port)
await server.serve_forever()`

bpy.app.timers.register(startServer, first_interval=5, persistent=True)

However I get the Error: 'bpy.app.timers' callback <function startServer at 0x000001CED12825E8> did not return None or float.

How can I call an async function from a timer? I want the server to listen to the local port indefinitely after startup. I tried using queue but had a similar issue.