How to pass values from a HTML form into a blender file? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to pass values from a HTML form into a blender file?

I want to take input from user through HTML form and pass it into blender file for designing simulations according to user input. I know that it can be done using Javascript but i don't know how?

27th Jul 2019, 1:44 PM
Chetali Shah
Chetali Shah - avatar
6 Answers
+ 2
That sounds like an interesting project. Depending on your specific needs, sending an HTTP request from JavaScript might not be needed. If you're not worried about reloading the entire page, you could just use a form that submits in a more classical way to a serverside script. If you really need the user to enter information without reloading the page, you could use jQuery and its ajax method documented at https://api.jquery.com/jquery.ajax/ The bigger challenge will be what your server does to the user input. It sounds like you're new to JavaScript and probably new to serverside programming yet your problem will need some serverside programming to connect with Blender. 1. What kind of information are you trying to pass to the server? - Updating 3D models? - Length of simulation run? 2. What kind of information do you want passed from the server to the client? - Rendered images? - Rendered video? - Updated 3D model files in a specific format? Python seems like a good serverside language since Blender also uses it for its API scripts. If you're sending data that should affect 3D models, you could write Python code to update .stl and .cad files. https://github.com/SolidCode/SolidPython can help with parsing and formatting those files. I didn't quickly find libraries for updating Blender files but you can probably work around this by running Blender from command line with different arguments to convert file formats and data.
27th Jul 2019, 5:33 PM
Josh Greig
Josh Greig - avatar
+ 1
I am trying to create virtual labs for physics. Input given by user will be the readings basically and output will be shown through a 3D model image through Blend4Web in a web page. So basically I want my lab to perform changes in itself according to user input.
28th Jul 2019, 9:11 AM
Chetali Shah
Chetali Shah - avatar
+ 1
I found a similar question at: https://www.blend4web.com/en/forums/topic/3305/ Verge3D might be good too. Verge3D looks similar to Blend4Web with a few of the same developers, high compatibility with Blender, and more recent updates. I'll try to install Blend4Web's community edition within a few days and see if I can learn enough to share more tips about it. This might involve copying a working demo, playing with minor changes to it without breaking it, and then making a viewable static model that can be rotated from user input and JavaScript written by me. I never heard of Blend4Web and it looks interesting especially when NASA used it for https://www.blend4web.com/en/demo/experience_curiosity/.
29th Jul 2019, 5:41 PM
Josh Greig
Josh Greig - avatar
+ 1
Ok... Thank you. I will wait for your next response.
29th Jul 2019, 6:33 PM
Chetali Shah
Chetali Shah - avatar
+ 1
Well, anything which gives the expected result is acceptable. I actually found Blend4Web as solution everywhere I searched so that's why I said for it. I'll check Verge3D and Blend4Web both and will pick one which suits the best according to requirement. The main issue I am facing right now is how to integrate the values entered in HTML form with Blender's values like rotation angles or x,y,z coordinates and so on to give user the output according to his input.
1st Aug 2019, 5:26 PM
Chetali Shah
Chetali Shah - avatar
0
I still haven't actually gotten it working on one of my computers but there are several tutorials showing how to. Are you sure you want Blend4Web or would Verge3D be acceptable too? Verge3D has more recent updates, tutorials, and You can download Verge3D from: https://www.soft8soft.com/get-verge3d/ on the "for Blender" tab. A good starting tutorial is at: Verge3D for Blender Basics - Part 1 - Creating New Project: https://www.youtube.com/watch?v=ibPSGArAfJM I hope to find time to install and play with this but I got busier than expected.
1st Aug 2019, 1:35 AM
Josh Greig
Josh Greig - avatar