- 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
- This reply was modified 7 months, 2 weeks ago by Alexander Kovelenov.
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 #207582020-04-09 at 6:58 pm #25597GlifTekLicensee
This is very interesting to me! Do you have any online examples of its functionality?
I’m not versed in python, but i s seriously like to keep track of these types of developments to share with future collaborators to accomplish certain results.
Thanks!2020-04-09 at 7:30 pm #25598
You can get Verge3d + Blender working in python using the steps I describe above (#20753) – note that if the bpy module doesn’t work, then you have to build it yourself. The tricky part is throwing Django in the mix, which I don’t describe here.
Depending on what you’re trying to accomplish, maybe I could give some guidance…? Otherwise, I can’t point you to a github example until I publish my research. Sorry!
-Jack2020-04-10 at 4:14 am #25606GlifTekLicensee
Well a while back I asked what member Ulock recently asked, which is about having objects dynamically load from a linked library scene or more depending…
Someone replied to me with the how to and I saved that info, soon to revisit it and attempt it.
They had it working, but noted that they, like me, “cobble” code for prose re: unfamiliar languages.
So if I get tripped up somewhere, I’ll know who to come and pester about it heheh
I’m also curious about integrating control over dynamic geometric generation based on multiple svg images. 2 at a time, rarely 3. Ie:lithographic views in 2D images to calculate a 3D result.
I know three.js has svg loaders and basic extrusion tools for such, which I’m learning, but there’s affects of it I’m thinking Blender’s armament of abilities would better solve.
Probably will have to chat with plug in writers… Like the guys who make boxcutter and the guy behind the Tissue plugin. (Fantastic for the iterative geometry style I’m in need of.)
Anyway, thanks for responding, and I’ll keep in touch!
You must be logged in to reply to this topic.