Controlling FreeCAD from external app in C++ / C# -possible?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Controlling FreeCAD from external app in C++ / C# -possible?
Hello everybody!!
I want to make application that will control (drive) FreeCAD. I know about API, and that there is possibility with Python macros (a lot of them are here on forum and wiki). I am asking if it is possible to drive FreeCAD from my "external" application (in C++ or C#)??
I want to make something like add-ons (you know them if you use commercial CADs). I am thinking about making something like GearTrax, GearTeq, GWJ eAssistant, etc. (with slightly different functionality).
I am interested to run FreeCAD, make geometry (FreeCAD will do it), save files and close FreeCAD.
Hope you can give me some directions!
If it is not possible with external app in C++/C#, please tell me at least how to make add-in in Python fully integrated with FreeCAD (I mean, I would like to have my button, menu items, and panels in FreeCAD). I mean I want to extend Part Design Workbench with my function(s) and give user GUI consistent with this in FreeCAD (Especially I am thinking about panel with options to configure my function/operation, etc.).
Regards.
TT-RS
PS. Hope you understand my "English"
I want to make application that will control (drive) FreeCAD. I know about API, and that there is possibility with Python macros (a lot of them are here on forum and wiki). I am asking if it is possible to drive FreeCAD from my "external" application (in C++ or C#)??
I want to make something like add-ons (you know them if you use commercial CADs). I am thinking about making something like GearTrax, GearTeq, GWJ eAssistant, etc. (with slightly different functionality).
I am interested to run FreeCAD, make geometry (FreeCAD will do it), save files and close FreeCAD.
Hope you can give me some directions!
If it is not possible with external app in C++/C#, please tell me at least how to make add-in in Python fully integrated with FreeCAD (I mean, I would like to have my button, menu items, and panels in FreeCAD). I mean I want to extend Part Design Workbench with my function(s) and give user GUI consistent with this in FreeCAD (Especially I am thinking about panel with options to configure my function/operation, etc.).
Regards.
TT-RS
PS. Hope you understand my "English"
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Controlling FreeCAD from external app in C++ / C# -possi
I'm not sure, but take a look at console mode of freecad. AFAIK it is possible to launch FreeCAD without GUI and feed python commands via stdin/whatever.
Re: Controlling FreeCAD from external app in C++ / C# -possi
hi
some tracks
Embedding_FreeCAD
Interface_Customization
https://docs.python.org/2/extending/embedding.html
https://docs.python.org/2/extending/extending.html
mario
some tracks
Embedding_FreeCAD
Interface_Customization
https://docs.python.org/2/extending/embedding.html
https://docs.python.org/2/extending/extending.html
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Controlling FreeCAD from external app in C++ / C# -possi
I think this is also good solution for me, if you or someone else know something more about it (how to so it) please share information....DeepSOIC wrote:I'm not sure, but take a look at console mode of freecad. AFAIK it is possible to launch FreeCAD without GUI and feed python commands via stdin/whatever.
The second solution (by mario52) using Python is OK, but in this case I would like to use different programming lamnguage.
Re: Controlling FreeCAD from external app in C++ / C# -possi
Another programing language for the command line version is not possible, freecad is tightly integrated with python, anything else won't work.
In general controlling annother program from c++ is possible as subprocess, but this basically only spawns the other app and gives minimal interaction possibility. Integrating two applications is in general not possible as both have seperate event queues etc...
It is not exactly clear what you want to do, but I think you should be really careful with the decision:
1. FreeCAD in console mode with python allows you to use the full freecad power in modeling terms, however, you won't have any gui. This means no 3d viewer etc...
2. FreeCAD Gui embedded in python program gives you all the modeling and the gui which can be controlled from you python program, but this is imho a bit cumbersome
3. If your c++ program uses QT for gui you can embed freecad widgets into your application easily. But FreecAD is a whole eco-system with workbenches,commands etc. and therefore it is not that simple to seperate stuff. And if you integrate the whole main window then you have the same as normal freecad.
4. Create a own freecad workbench with the stuff you like to do. Easy, can be done in c++ or python (or both together) and gives acceess to everything.
If you like to make addons then a custom workbench (the freecad equivalent of an addon) is imho the simpelst thing. But of course I don't know your requirements,
In general controlling annother program from c++ is possible as subprocess, but this basically only spawns the other app and gives minimal interaction possibility. Integrating two applications is in general not possible as both have seperate event queues etc...
It is not exactly clear what you want to do, but I think you should be really careful with the decision:
1. FreeCAD in console mode with python allows you to use the full freecad power in modeling terms, however, you won't have any gui. This means no 3d viewer etc...
2. FreeCAD Gui embedded in python program gives you all the modeling and the gui which can be controlled from you python program, but this is imho a bit cumbersome
3. If your c++ program uses QT for gui you can embed freecad widgets into your application easily. But FreecAD is a whole eco-system with workbenches,commands etc. and therefore it is not that simple to seperate stuff. And if you integrate the whole main window then you have the same as normal freecad.
4. Create a own freecad workbench with the stuff you like to do. Easy, can be done in c++ or python (or both together) and gives acceess to everything.
If you like to make addons then a custom workbench (the freecad equivalent of an addon) is imho the simpelst thing. But of course I don't know your requirements,
Re: Controlling FreeCAD from external app in C++ / C# -possi
Thanks for reply, I asked because I wanted to make one appplication for few CAD systems (Windows based only). Now I see it is rather hard and I decided to make two apps (Cross-platform one for FreeCAD + Windows based for the rest of CAD systems).
Re: Controlling FreeCAD from external app in C++ / C# -possi
I don't understand what you mean by that, could you provide more information?TT-RS wrote:Thanks for reply, I asked because I wanted to make one appplication for few CAD systems (Windows based only). Now I see it is rather hard and I decided to make two apps (Cross-platform one for FreeCAD + Windows based for the rest of CAD systems).
Re: Controlling FreeCAD from external app in C++ / C# -possi
@jmaustpc - I meant I wanted to make one app in C++ or C# for Windows environment for few CAD packages (not only FreeCAD, but also SW, SE and maybe also Inventor).
Re: Controlling FreeCAD from external app in C++ / C# -possi
Are you saying that you want to make one application that embeds FreeCAD, SW etc... as in effect some sort of plug ins to your application. So you would start your application and then have it run FreeCAD, SW etc...TT-RS wrote:@jmaustpc - I meant I wanted to make one app in C++ or C# for Windows environment for few CAD packages (not only FreeCAD, but also SW, SE and maybe also Inventor).
Or are you saying that you want to make an application that is some sort of a plug-in that can be plugged into FreeCAD or SW etc.... In which case a user would start FreeCAD or SW etc. and then use FreeCAD SW etc... to start your application.
Re: Controlling FreeCAD from external app in C++ / C# -possi
Ofcourse that would be several applications (one for each CAD system, but - firstly I wanted them to develop - all in one language and for one platform (Windows)), I hoped to have re-use most of code ("engine" + same GUI) in them. I have already made simple app ("Hello world" kind ) that works fine for SW & SE.
I plan to make something like GearTrax / GearTeq / eAssistant but with different objects to generate (less gears, more other stuff).
I plan to make something like GearTrax / GearTeq / eAssistant but with different objects to generate (less gears, more other stuff).