Communicate with FreeCAD on a Server from a Web Browser

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
dorogz
Posts: 13
Joined: Sat Feb 07, 2015 9:25 pm

Communicate with FreeCAD on a Server from a Web Browser

Postby dorogz » Sat Feb 07, 2015 10:12 pm

I've been paying great attention to FreeCAD for some time and now I wish to get into some action... but I have just no clue on how to go about this:

I envisage a scenario in which FreeCAD runs on a web server like Apache and a model on an instance of FreeCAD on the Apache Server can be remotely steered from a web browser. Maybe a web service would accept commands from a web browser, channel them to an instance of FreeCAD through HTTP. When the command is processed by FreeCAD, the response is then sent back to the web browser and the user views the effected changes on the steered model in 3D. At the end, the user could save and obtain the CAD file in a specific format ...

Has anyone got an idea on how I could go about realizing such a scenario with FreeCAD? Any suggestions for an architectural design and technologies/techniques that could be involved?

Browser (WebGL) ---> HTTP ---> Apache ---> FreeCAD ---> Apache ---> HTTP --> Browser(webGL)
User avatar
rockn
Posts: 1636
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby rockn » Sun Feb 08, 2015 12:25 am

Hi dorogz,
I personnaly make such an usage of FreeCAD to generate a custom Wooden Pergola.
It's a form where you enter values of your desired structure, when you click on the "Construire" button it launch a FreeCAD script that generate the structure then export it in WebGl then I display the webgl file in an Iframe.
You can try that here :
http:// wood3dservices dot com:8888 (I make the link unclickable because it's use a pretty huge ressources and it's on a little server at home, please don't set huge values in the form ;) )
Of course the script can create what you want (all possible export format supported by FreeCAD, even Drawings)

I was inspired by danielfalck work : https://github.com/danielfalck/freecadweb

So it need a web server, mine is nginx (in fact I'm not sure it's needed), a Tornado server, a FreeCAD installation, and FreeCAD scripts. If I remember well (yes I made this 2 years ago). The Tornado server display the form generated by a python script, then it's launch the FreeCAD script by passing argument from the form, the script make the file and Tornado display an html page that embedded the webgl file.

Not sure it's clear but it can give you some idea.
Formations et tutoriels FreeCAD en Français, soutenez moi : https://www.tipeee.com/formations-freecad
dorogz
Posts: 13
Joined: Sat Feb 07, 2015 9:25 pm

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby dorogz » Sun Feb 08, 2015 7:43 am

Hello rockn,

thanks for the prompt reply! Thanks a lot for the information and the links! Your implementation is ample proof that my ideas can be realized. I have tested the resource on your server and I've also read through Daniel's repo on github! This information is definitely helping in shaping my thoughts!

Question: After configuring the Wooden Pergola, is it possible to effect any changes on the model in the browser? For example; double-click, change value of a parameter and recompute?
kwahoo
Posts: 275
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby kwahoo » Sun Feb 08, 2015 10:06 am

Hi,
If you want read more about WebGL export itself, check this thread.

I created an alternative WebGL exporter (different shading, Three.js-free,) some time ago, feel free to test if you want https://github.com/kwahoo2/nwgl
User avatar
rockn
Posts: 1636
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby rockn » Sun Feb 08, 2015 1:21 pm

@dorogz : No, you can't interact with the model, I have make research to be able to take measure directly in the webgl view but it need to code in the three js file and I don't have knowledge to do.

But I think you can easily imagine that the form and the webgl view are display on the same page, then you have just to change values in the form to refresh the model...
Formations et tutoriels FreeCAD en Français, soutenez moi : https://www.tipeee.com/formations-freecad
wmayer
Site Admin
Posts: 15755
Joined: Thu Feb 19, 2009 10:32 am

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby wmayer » Sun Feb 08, 2015 6:28 pm

dorogz
Posts: 13
Joined: Sat Feb 07, 2015 9:25 pm

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby dorogz » Sun Feb 08, 2015 8:57 pm

@kwahoo:
nwgl is succinct and awesome ... thanks a lot! I also dug into the thread too and found very useful information. I was led to the following links --
mod-wsgi : https://code.google.com/p/modwsgi/
SceneJS : http://xeolabs.com/articles/scenejs-quick-start/
WebPython : http://webpython.codepoint.net/
I am gradually piecing this information together to help me decide on a line of action.

@rockn
Thank you for the information!

@wmayer
Thanks very much for the link!

I'd like to work with Apache and of course use Python as scripting language. I think my next steps will be to install FreeCAD on a machine with Apache and work on channeling commands/parameters from a Web Browser to FreeCAD through Apache and then get a response from FreeCAD through Apache to the Web Browser. kwahoo's nwgl will surely be used here for visualization.

Mabe someone has a clue to get me going. As always, I would appreciate any insight!
marcin_ose
Posts: 18
Joined: Wed Apr 29, 2015 9:20 pm

Re: Communicate with FreeCAD on a Server from a Web Browser

Postby marcin_ose » Fri Apr 27, 2018 8:49 pm

<t>Dorogz - did you give this any more thoughts since 2015? I'd like to hear any new insights that you may have.<br/>
<br/>
Marcin</t>
Founder, Open Source Ecology
http://opensourceecology.org/