npolet Posted September 17, 2015 Share Posted September 17, 2015 I am trying to call the blender exporter addon from within another script in blender. The idea is that, when someone saves the blender file, a .babylon file is also created, alongside the .blend file. Within blender, I can add a function to the post_save array, which will be called after every save.def save_handler(dummy): scene = bpy.context.scene // Trying to export the babylon file here bpy.ops.scene.babylon()bpy.app.handlers.save_post.append(save_handler)But bpy.ops.scene.babylon() doesn't seem to work. I'm just unsure of how to call the export function for babylon in other scripts etc... I have got as far as adding an 'Autosave' setting to the babylonjs settings panel, but cannot run the export script within the save_post function. Any pointers on how to get this going? I hate having to manually export the babylon file from blender each time I make changes to a file, and I thought that automatically exporting on each save would be a nice feature to the addon. Will hopefully submit a pull request if I get a decent solution. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 17, 2015 Share Posted September 17, 2015 Cannot help you, but think you would need to modify the exporter. Reason being is when it is executed, it brings up a dialog to specify the directory & file name Quote Link to comment Share on other sites More sharing options...
npolet Posted September 17, 2015 Author Share Posted September 17, 2015 Found a temporary solution which seems to be working just fine. I've added a little checkbox in a Babylonjs panel that generates a .babylon file when you save the blender file. Much nicer than having to "File >>> Export >>> Babylon.js" etc... If anyone is interested, you can see the changes I made here in my fork of babylon. ChrisR 1 Quote Link to comment Share on other sites More sharing options...
cefleet Posted September 30, 2015 Share Posted September 30, 2015 That is pretty cool. Thanks for sharing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.