- 2019-10-18 at 6:12 pm #20457
I hope I’m not asking too much, but I felt that posting here would be better than the general Blender forums! Anyways, I think Verge3D is an awesome opportunity to establish python-backend 3D-model scripting — that is script the creation of *.gltf and *.bin files for online viewing. You could reach out to many developers that stick with python (i.e. all Django users).
I’m trying to set this up currently, but am struggling to get the Blender+Verge3D code working as an independent python module. The end goal to be able to run the following example script in an anaconda environment:123456789101112# import the blender python module (with Verge3D add-on)import bpy<< code that makes 3D-model goes here >><< code that edits verge3D settings >># save the *.blend file createdbpy.ops.wm.save_as_mainfile(filepath='C:/Users/jacks/Desktop/example.blend')# export the file using Verge3D gltf (with compressed files)bpy.context.scene.v3d_export.lzma_enabled = Truebpy.ops.export_scene.v3d_gltf(filepath="C:/Users/jacks/Desktop/example")
Making bpy as a standalone python module has been done before (see here: https://anaconda.org/kitsune.one/python-blender) (and here: https://pypi.org/project/bpy/), but I can’t figure out how to replicate this for Blender 2.80 with Verge3D functionality.
Does your team have any insight on how to do this? Or is there alternative method to scripting *.blend/*.gltf/*.bin files that you’d suggest?
Any help is greatly appreciated!!
-Jack2019-10-19 at 8:27 am #204632019-10-19 at 3:25 pm #20475
I do have scripts successfully running by that method, but that’s actually the reverse of what I’d like to do! With this approach, you always need to run scripts via the ‘blender’ command, which in turn checks for a built-in python. You also can remove the built-in python from blender, and the ‘blender -P’ command will fall back to the system’s default python. That’s a step in the right direction, but it’s not useful for when you want to add bpy functionality to your existing scripts without being forced to use the ‘blender -P’ command instead of ‘py’.
In my case, I have a conda enviornment with a bunch of high-level modules (django, scipy, plotly, pymatgen, etc.), where I’d add bpy to the server’s functionality — rather than change to running every app/script with the command ‘blender’ instead of ‘py’. If this is possible, then the bpy module becomes much much more accessible to those that have complex environments already built – particularly those that run a django server and those in data science research (like me!).
The two links that I sent in my original post make the stand-alone python module for blender — I’d like to replicate that with blender 2.80 + Verge3D. So far I’m struggling to do this, but I have since found instructions on building Blender (without Verge3D): https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule
I’m close, but I need help building the module with Verge3D incorporated. Alternatively, we can make a bpy module via the method in the link above and then make a separate Verge3D module that uses bpy as a dependency. I’m not sure which route would be easiest.
-Jack2019-10-20 at 10:34 am #20492
thanks for the clarification! I’ve never heard about this BlenderAsPyModule project. So the only thing remains is to import Verge3D addon properly and get access to its features. Have you tried doing something like:123>>> import sys>>> sys.path.append('~/verge3d/addons/verge3d')>>> import verge3d
Replace ‘~/verge3d/addons/verge3d’ to the actual path to Verge3D addon.2019-10-21 at 12:51 pm #20513
I’ll give this a go! If I get a working build, I’ll upload to anaconda for others to use as well. Thank you!
-Jack2019-10-21 at 8:23 pm #20531
I’m unfortunately unable to get this to work. bpy looks like it loads all add-ons when it initializes, so verge3D needs to be in that directory when I use ‘import bpy’. I’ve also tried this, but I’m still getting errors.
Currently bpy (as installed via anaconda : https://anaconda.org/kitsune.one/python-blender) throws an error with all add-ons. Trying to make my own build of bpy is failing at the build stage as well — though this is just because of my inexperience with cmake.
I’ve even tried adding all of blender’s python path to my external python, but without any luck there. Errors are thrown when the module tries importing binaries (e.g. import _bpy).
I’ll likely link this discussion to a post in the general blender forums because I need help with the build bpy module.
-Jack2019-10-22 at 2:28 pm #20596
Yep, you better ask Blender developers for that.
Verge3D comes with no binaries and no external dependencies so I believe it should be pretty straightforward to import it, once you have more information on how to deal with Blender addons in your setup.2019-10-28 at 1:27 pm #20753
So I finally got this working! Here are the steps that I followed:
– Create an anaconda enviornment based on python 3.7
– Install blender as a python module from https://anaconda.org/kitsune.one/python-blender
– Download Verge3D (for Blender) from https://www.soft8soft.com/get-verge3d/
– From the verge3d download, copy the verge3d/addons/verge3d folder into C:/Users/jacks/Anaconda3/envs/blender_env/2.79/scripts/addons
– Now open up spyder with the blender_env active and run the following:
NOTE: ‘import bpy’ will throw a bunch of errors/warnings, but this is fine! Error error is associated with blender trying to initiate Blender’s GUI features — which we aren’t using. This will also happen when you enable verge3d. Base functions will still work as intended though.2019-10-28 at 1:54 pm #20758
You must be logged in to reply to this topic.