Get FreeCAD model information through FreeCAD WEB server

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Get FreeCAD model information through FreeCAD WEB server

Post by dcapeletti »

Hello, some time ago I was testing the Web module that comes with FreeCAD. To start the server in the FreeCAD console:

Code: Select all

import Web
Web.startServer()
('0.0.35.130', 44409)
Now FreeCAD creates a socket to accept connections on port 44409.
To connect from the outside I made this class RemoteFreeCAD https://gitlab.com/dcapeletti/RemoteFre ... FreeCAD.py
In a python console we write:

Code: Select all

from RemoteFreeCAD import *
client = RemoteFreeCAD('localhost', 44409)
At this point we have a client connected to the FreeCAD web server.

If we want to send a message to the server to modify the model, we use the send function of the RemoteFreeCAD class. In this class there are several experimental functions to create and modify objects from a client. Some of them are:
crearDocumentoNuevo: Creates a new document from a connected client. Example

Code: Select all

client.crearDocumentoNuevo()
crearNuevoCubo: Creates a new cube with predefined sizes if they are not rewritten in the function parameters.

Well, after having shown what I have done, now I wonder how it can be possible to query model information using the FreeCAD web server. There must be some get function or something like that in the web server that can query information from the model and return it to my client, but I still can't find the way to do it. For example, if I want to query dimensions, list of objects, among other things.

Any help?

See video in Spanish https://www.youtube.com/watch?v=h-przvn0neI
Post Reply