create a workbench by C++ and fcbt tool
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
create a workbench by C++ and fcbt tool
Hello, everyone. I want to create a workbench. I tried to use the fcbt.py tool to create a workbench. After there are myworkbench folder, when I open the FreeCAD and active it, FreeCAD told me that 'No module named 'myworkbenchGui'. I know that it is wrong to do so. I guess that I need to use CMake or compile it? but I don't know what to do. Thank you!
Re: create a workbench by C++ and fcbt tool
From this page, it seems that a C++ WB have to be only the "entry point" in Python, but the rest of the Wb must be coded in C++
https://wiki.freecadweb.org/Workbench_creation
Sadly there are not much information about, but as example if you see:
https://github.com/FreeCAD/FreeCAD/tree ... d/TechDraw
It is mostly If not entirely coded in C++ with only initialisation file and test files in Python.
You have to code the whole Wb or at least a skeleton and compile it to have something to invoke, and myworkbenchGui is clearly only the "fake name" to show an example of class name that has to be created in C++ code.
Sadly there is no more documentation around on how to create C++ WB, so probably you have to wait some more skilled developer to have some answers.
Where you have found fcbt.py file? I have some vague remember of a tool that will create a skeleton for workbenches, but from what I remember it was for Python WB.
Hope it helps.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: create a workbench by C++ and fcbt tool
Thank you for your reply! Here are some official introductions for fcbt.https://wiki.freecad.org/FreeCAD_Build_Tool/en
Re: create a workbench by C++ and fcbt tool
Hello, I' ve seen, but it is simply putting some files in the Mod directory.xc22143 wrote: ↑Mon Sep 26, 2022 6:59 am Thank you for your reply! Here are some official introductions for fcbt.https://wiki.freecad.org/FreeCAD_Build_Tool/en
It is not clear from the page linked if it create a Python or a C++ file, as I have not tried it, but in both cases, the skeleton should be completed to have even a "do nothing" Module.
Sadly there are not much information about WorkBench creation, you could inspect some code already created, you will find many here:
https://github.com/FreeCAD/FreeCAD-addons
Most of them are Python WB, for C++ WB you have to search and find some not too complicated.
I have not much to say, as C++ is not my best known language and I have only scratched the surface of WB in Python.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: create a workbench by C++ and fcbt tool
if you don't know how to compile, are you sure you want to do your workbench in C++? I would go with a pure python workbench instead, way easier to write and test.
Re: create a workbench by C++ and fcbt tool
Sorry, I'm not familiar with compiling, but I have to use C++ right now. I successfully compiled FreeCAD according to the compiled wiki documentation, now I created a new workbench by fcbt tool, I don't know if I need to re-build all the source code in Cmake and then recompile all in VS.adrianinsaval wrote: ↑Mon Sep 26, 2022 11:52 am if you don't know how to compile, are you sure you want to do your workbench in C++? I would go with a pure python workbench instead, way easier to write and test.
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: create a workbench by C++ and fcbt tool
why? Are you sure? Creating a C++ workbench without even knowing how to compile seems like a pretty big challenge to me. I'm not familiar with the output of fcbt tool but you probably need to add/edit the corresponding cmake files to get your workbench to compile. But let's start with the basics, have you compiled FreeCAD before?
Re: create a workbench by C++ and fcbt tool
Thank you for your advice. Because my company requires it. I compiled FreeCAD successfully step by step according to the wiki documentation. But I don't understand the principle of compiling behind. It is indeed a pretty big challenge. anyway, thank you very much.adrianinsaval wrote: ↑Mon Sep 26, 2022 12:39 pmwhy? Are you sure? Creating a C++ workbench without even knowing how to compile seems like a pretty big challenge to me. I'm not familiar with the output of fcbt tool but you probably need to add/edit the corresponding cmake files to get your workbench to compile. But let's start with the basics, have you compiled FreeCAD before?
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: create a workbench by C++ and fcbt tool
Then your manager or whoever made that decision is an idiot, they should hire someone with C++ knowledge if they want a C++ workbench or pay for the training if they want an existing employee to do it, otherwise, use python (well they should still hire someone who knows it or train their employee but this should be easier and possibly cheaper).
I don't know a lot of how cmake works either so I suggest you start by reading about it, don't try to learn it along the way if you are working in a serious project (same goes for actual C++), you'd be setting yourself up for trouble. Perhaps create a simple project independent of FreeCAD to start getting accustomed to it.
If you have added your workbench to src/Mod and you want it to get compiled with FreeCAD you need to add it here: https://github.com/FreeCAD/FreeCAD/blob ... eLists.txt and you need a CMakeLists.txt in your addon directory too where you will tell it what files have to be compiled, generated, copied over, etc. See the other C++ workbenches for examples.
Also for future inquiries it might help to know for what platform you are compiling and what version of FreeCAD so you should probably provide that information.
I don't know a lot of how cmake works either so I suggest you start by reading about it, don't try to learn it along the way if you are working in a serious project (same goes for actual C++), you'd be setting yourself up for trouble. Perhaps create a simple project independent of FreeCAD to start getting accustomed to it.
If you have added your workbench to src/Mod and you want it to get compiled with FreeCAD you need to add it here: https://github.com/FreeCAD/FreeCAD/blob ... eLists.txt and you need a CMakeLists.txt in your addon directory too where you will tell it what files have to be compiled, generated, copied over, etc. See the other C++ workbenches for examples.
Also for future inquiries it might help to know for what platform you are compiling and what version of FreeCAD so you should probably provide that information.
Re: create a workbench by C++ and fcbt tool
Thank you very much!!! I need to learn more.