Hello to All.
I'm trying to write a workbench for freecad.
It scope is to import and visualize a file created by CamBam (a simple but powerful CAD CAM written in C#).
I've some problems:
I have found some tutorials and I've set up a skeleton for the workbench, but I'have not found a way to:
1) Add a Tab in teh ComBo View when I activate the workbench, so I can load the file and operate on it, as in this tab I've to lad the structure of the xml document and operate on it. (The scope is to visualize and copy the entity from and existing xml file to another xml file compatible with CamBam)
2) Access some python module outside the AppImage as outside Freecad the modules are accesible but in the Appimage the modules are reported as not found.
Running Devuan Linux (Debian Stretch without systemd) I could not find a package that fit my distribution (Ubuntu is supported but is slightly different from Debian, so the AppImage is the only viable solution)
I'm using FreeCAD 0.17 fAppImage downloaded from the official repository on github.
Many Thanks and regards
Carlo D.
Writing a workbench in Python
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Writing a workbench in Python
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: Writing a workbench in Python
For the question number 2 I've tryied
but I wonder if there will be some conflicts in doing this?
I have resolved also the problem number 1.
TIA and regards
Carlo D.
Code: Select all
import sys
sys.path.append("/usr/lib/python2.7/dist-packages/")
I have resolved also the problem number 1.
TIA and 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: Writing a workbench in Python
Could very well be. The AppImage uses Ubuntu 14.04 (Trusty) assets ie PY3.4
Some work being done in this regard here: https://forum.freecadweb.org/viewtopic. ... 4&start=30
"fight the good fight"
Re: Writing a workbench in Python
So there is a safe way to integrate the AppImage with the missing libraries?
I have some troubles finding the API documentation,
My actual problem is:
I have created my workbench
I have found the way to create a document and add the draft object to it, but:
1) how to activate the grid in the Draft view in the window, doing Draft.show(object) the object is shown but the grid is not and the object is not centered
2) there is a manner to obtain the API, looking maybe at the github sources?
TIA and Regards
Carlo D.
I have some troubles finding the API documentation,
My actual problem is:
I have created my workbench
I have found the way to create a document and add the draft object to it, but:
1) how to activate the grid in the Draft view in the window, doing Draft.show(object) the object is shown but the grid is not and the object is not centered
2) there is a manner to obtain the API, looking maybe at the github sources?
TIA and 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: Writing a workbench in Python
Ok Now I've managed to get the grid, using an hack:
I wonder if there is a more clean manner.
The color of the grid is fixed or it could be changed in python?
And I've added a tab in the comboview, but i couldn't make it the tab on top (so it is viewable).
I have saved the widget in a variable and I thought it would be able to be retrieved with
but it gave an error about the original widget is destroyed.
TIA and regards
Carlo D.
Code: Select all
FreeCADGui.activateWorkbench("DraftWorkbench")
Draft.setParam("alwaysShowGrid", True)
Draft.setParam("gridSize",800)
#Draft.setParam()
FreeCADGui.SendMsgToActiveView("ViewFit")
FreeCADGui.activeDocument().activeView().viewTop()
if hasattr(FreeCADGui,"Snapper"):
FreeCADGui.Snapper.grid.on()
FreeCADGui.Snapper.forceGridOff=False
FreeCADGui.activateWorkbench(""MyWorkBench)
The color of the grid is fixed or it could be changed in python?
And I've added a tab in the comboview, but i couldn't make it the tab on top (so it is viewable).
I have saved the widget in a variable and I thought it would be able to be retrieved with
Code: Select all
Comboview.IndexOf("widget saved")
TIA and 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/