2
$\begingroup$

I made a script that turns pixels into polygons:
https://github.com/doyousketch2/PixelDraw.py

But it slows down with each new row of pixels.
After 50 or so rows, you notice it.

I'm trying to Cythonize it, but I don't know
how you'd go about running the setup script within Blender...

I get that you can use external modules this way:

sys.path.append('/usr/local/lib/python3.4/dist-packages/')

But you can't use the one-line trick:

import pyximport; pyximport.install()

because it uses external modules; bpy for instance.

If I try to compile it outside of Blender, I run into errors.
Most likely Python version mismatch issues.

Is there an important step I'm missing?

$\endgroup$
7
  • $\begingroup$ What you are doing sounds tricky and may not work, I don't know enough about all the linking details here. Have you done much profiling on you current script? It may be there are a few tricks to optimise it as it stands (I suspect the object creation per pixel may be slow, but would need testing, you may be better off creating verts within a single mesh). The other option is to write it as a standalone script that spits out an obj file, and just import that. $\endgroup$
    – Sazerac
    Mar 14, 2017 at 2:49
  • $\begingroup$ Yeah, I was thinking of creating n'gons from individual verts based on color. It would take an entire re-write of the code to produce. I agree it would most likely be faster, as it would just put down one polygon per color. I do like the other idea. I did a similar script to create 3D cactii - scratch.mit.edu/projects/71182224 - so I guess that's always a possibility. Was just hoping to see a speed up using Cython, 'cuz that's what it's made for. Then I could use the same technique to speed up other scripts as well. $\endgroup$ Mar 14, 2017 at 3:14
  • $\begingroup$ I suspect if it were easy to get done we would have seen it done a lot more with blender scripts, since a lot run into performance issues. Good luck anyway. $\endgroup$
    – Sazerac
    Mar 14, 2017 at 3:18
  • $\begingroup$ You can have a look to graphicall.org/1202. But I have read your .py and my guess is that most of the runtime is into bpy.ops and creating materials. So compiling your own code won't change so much the result $\endgroup$
    – lemon
    Mar 14, 2017 at 6:25
  • $\begingroup$ I suspect you're right about the runtime. Ty for the example. He ran setup.py right within the script window. I guess I was expecting that you had to drop out to a commandline to do so. It didn't occur to me that you could just run setup in there, then load the other script after everything is compiled. It makes sense now that I see it, but at the time, it just wasn't how I expected to use Blender. I'll play around with it later on and see if I can get somewhere with it, and if makes any difference. $\endgroup$ Mar 14, 2017 at 6:54

0

You must log in to answer this question.

Browse other questions tagged .