At present, I am developing Workbench and can realize some simple functions.
However,I don't know how FreeCAD and Workbench exchange data, the interface between them,or how does FreeCAD recognize user actions in the Workbench?
Is it APP and Gui?Does anyone know, thanks.
OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
[Solved]:How is data exchanged between FreeCAD and Workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[Solved]:How is data exchanged between FreeCAD and Workbench
Last edited by xianyu on Thu Jul 07, 2022 7:01 am, edited 2 times in total.
Freecad novice, A Python enthusiast
Re: Question:How is data exchanged between FreeCAD and Workbench
Does Workbench_creation help at all ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Question:How is data exchanged between FreeCAD and Workbench
Thanks for your reply.
My workbench creation learned this Workbench creation → FreeCAD commands →Python command definition ,but I still don't know how they exchange data.
For example, in the Part workbench,i want to add optical properties to a surface of the cube, such as smooth, rough, etc. How does FreeCAD know which surface I have selected?
My workbench creation learned this Workbench creation → FreeCAD commands →Python command definition ,but I still don't know how they exchange data.
For example, in the Part workbench,i want to add optical properties to a surface of the cube, such as smooth, rough, etc. How does FreeCAD know which surface I have selected?
Freecad novice, A Python enthusiast
Re: Question:How is data exchanged between FreeCAD and Workbench
Is using FreeCAD. and FreeCADGui.?
Freecad novice, A Python enthusiast
Re: Question:How is data exchanged between FreeCAD and Workbench
@Chris_G can you offer any good explanations/tutorials for @xianyu to follow?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Question:How is data exchanged between FreeCAD and Workbench
First of all, Please put your FC info using the instruction done in:
http://forum.freecadweb.org/viewtopic.php?f=3&t=2264
Without them answers could not be correct as some thing change between versions, and sometimes even with "Python version" hat could be different depending on the way FC is compiled and what OS you use.
Without some code is difficult to tell you how things works!
It is difficult to put together a code that is rather complex.
Some rough and not technically correct explanation:
Rough explanation FC is composed by two parts:
1) FreeCAD that is also called an referred as App that is the "modelling engine" part
2) FreeCADGui that is also called Gui that is the "visualization Part" i.e the GUI but not only.
These part are related, and are working together when you use the FreeCAD program.
Roughly the "modelling engine" Part is realted to the "Data" Tab on the ComboView and the "visualization Part" is in the "View Tab".
What you select is managed usually by the Gui part and you could obtain it using:
Code: Select all
selection = FreeCADGui.Selection.getSelectionEx()
l_sen = len(selection)
if l_sen != 1:
msg = f"You have selected <b>{l_sen}</b> shape(s)<br>"
msg += "You must select only 1 shape <br>"
print(msg)
else:
do_something(selection)
Hope it helps
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: Question:How is data exchanged between FreeCAD and Workbench
I'm so sorry, I ignored FC information.onekk wrote: ↑Fri Jul 01, 2022 12:04 pmCode: Select all
selection = FreeCADGui.Selection.getSelectionEx() l_sen = len(selection) if l_sen != 1: msg = f"You have selected <b>{l_sen}</b> shape(s)<br>" msg += "You must select only 1 shape <br>" print(msg) else: do_something(selection)
Yes, I have read about APP and Gui on wiki.
This code is FreeCAD recognizes the user's selection operation? What if I want to select a face in the cube
Code: Select all
selection = FreeCADGui.Selection.getSelectionEx()
Does this still apply?
https://wiki.freecadweb.org/Selection_API/de
Freecad novice, A Python enthusiast
Re: Question:How is data exchanged between FreeCAD and Workbench
once you have the shape you could takecwhat is into the shape.
The page you linked is correct.
Sekection should return even the subshape, try to search for getSelection in the forum and you will probably find some hints on usage
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/