Difference between revisions of "Power users hub"

From FreeCAD Documentation
Jump to navigation Jump to search
m (Removed and updated broken links about Pivy. Added more informative links about Pivy. Removed '.' at end of line for consistency.)
 
(69 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[Image:Crystal_Clear_app_terminal.png|right|150]]
+
<languages/>
 +
[[Image:Power_user_hub.png|64px]]
 +
----
 +
__NOTOC__
 +
<translate>
  
This is the place to come if you want to have a deeper insight into FreeCAD. Here you can learn about customizing FreeCAD for your needs.  
+
<!--T:2-->
 +
This is the place to come if you are an experienced user and want to learn more about customizing and extending FreeCAD.
  
These pages are in early stage of development. If you can't find the information you are looking for, or have found useful information somewhere we have not linked to, then please leave a comment on [[Talk:Power_users_hub|the talk page]], or, why not? Add some more content here yourself!
+
<!--T:4-->
 +
FreeCAD is extensible by [[Python|Python]] code that is run directly in the [[Python_console|Python console]], or that is loaded from modules at startup. This means that you can modify FreeCAD without needing to recompile the program. For example, you can:
 +
* '''Create and modify geometry''': you can create a new object type, either from scratch or by adapting an existing type.
 +
* '''Create custom tools and commands''': add your own set of tools that run your code.
 +
* '''Modify the interface''': create toolbars to put your tools, create special windows, panels, or interfaces for interacting with your tools.
 +
*'''Modify the scenegraph representation''': FreeCAD has separate processes for building up the geometry and displaying that geometry on screen. You have full access to the way the scene contents are displayed on screen, therefore you can modify that representation, interact with it, or add custom behaviour to it. You can also add custom screen widgets, like information, draggers, anchors or temporary entities.
  
One of the nicest features of FreeCAD is that you can script and extend it extremely far without the need to compile anything or touch the source code. All the scripting part is done in [http://en.wikipedia.org/wiki/Python_(programming_language) python], a very powerful but simple programming language. With simple python scripts, you have total access to about any part of Freecad. For example, you can:
+
<!--T:3-->
* '''Create and modify geometry''': There is a kind of special object you need but that's not present in the default FreeCAD installation? You can easily create a new object type, either from scratch eiter from adapting an existing type.
+
If you'd like to contribute content to these pages, request a wiki account with editor permissions [https://forum.freecadweb.org/viewtopic.php?f=21&t=6830 in the forum], and read the [[WikiPages|WikiPages]] for the general guidelines that you should follow. For other ways to contribute with the project, see the [[Help FreeCAD|Help FreeCAD]] page.
* '''Create custom tools and commands''': At the moment, FreeCAD already has extensive functionality, but there aren't many convenient tools and commands for the final user yet. But it is already easy to create your own sets of tools.
 
* '''Modify the interface''': The FreeCAD user interface is still very basic at this stage. But everything is there for you to extend it to your needs. You can, for example, create toolbars to put your own tools, create special panels for interacting with your tools, etc.
 
*'''Modify the scene representation''': FreeCAD has separate processes for building up and computing the geometry and displaying that geometry on your screen. You have full access to the way the scene contents are displayed on screen, therefore you can modify that representation, interact with it, or add all kinds of custom behaviours and screen widgets, like information, draggers, anchors or temporary entities.
 
  
== Customizing FreeCAD ==
+
== Customizing FreeCAD == <!--T:5-->
  
* [[Interface Customization]]: Starting with the beginnig: Toolbars and shortcuts
+
<!--T:6-->
* [[Macros|Working with Macros]]: Easily record often repeated tasks or python code
+
* [[Interface Customization|Interface Customization]]: Starting with the beginning: Toolbars and shortcuts
 +
* [[Macros|Working with Macros]]: Easily record often repeated tasks or Python code
 +
* [[Macros_recipes|Macros recipes]]
 +
* [[Customize_Toolbars|Customize Toolbars]]
 +
* [[Installing_more_workbenches|Installing more workbenches]]
  
== Scripting in FreeCAD ==
+
== Scripting in FreeCAD == <!--T:7-->
  
'''General'''
+
===General=== <!--T:8-->
* [[Introduction to python]] - See also other python tutorials at the bottom of this page
+
* [[Introduction to Python|Introduction to Python]] - See also other Python tutorials at the bottom of this page
* [[FreeCAD Scripting Basics]]: Well, the basics...
+
* [[Python scripting tutorial|FreeCAD scripting tutorial]] - A general look at python scripting in FreeCAD
* [[Gui Command]] : Adding custom commands to the GUI
+
* [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]]: Well, the basics.
* Using mixed [[Units]] in FreeCAD
+
* [[Gui Command|Gui Command]]: Adding custom commands to the GUI
 +
* Using mixed [[Units|Units]] in FreeCAD
 +
* [[Profiling|Profiling]] the Python code
  
'''Working with Meshes'''
+
=== Modules === <!--T:28-->
* [[Mesh Scripting]]: How to interact with the [[Mesh Module]]
 
  
'''Using OpenCasCade'''
+
<!--T:29-->
* [[Part Module|The Part Module]]: How OpenCasCade tools and structure is used in FreeCAD
+
The functionality of FreeCAD is separated in Modules which deal with special data types and applications. FreeCAD has built-in modules and Extension Modules (plug-ins). Once plugin modules are installed, they become availible to you as easily as the built-in modules. The modules described below are the default modules, includeed in every FreeCAD installation.
* [[Topological data scripting]]: How to interact with the Part Module
 
* [[pythonOCC]]: How to unleash the whole OpenCasCade power
 
* [[Mesh to Part]]: Converting between object types
 
  
'''Accessing the Coin scenegraph'''
+
<!--T:30-->
 +
* The [[Builtin modules|Builtin modules]] are the principal FreeCAD modules. They contain tools for manipulating general FreeCAD configurations, documents and their contents.
 +
* [[Workbench creation|Workbench creation]] shows you how to create your own workbench
 +
 
 +
====Working with Meshes==== <!--T:9-->
 +
* [[Mesh Scripting|Mesh Scripting]]: How to interact with the [[Mesh Module|Mesh Module]]
 +
 
 +
====Working with Parts==== <!--T:10-->
 +
* [[Part Module|The Part Module]]: How [http://en.wikipedia.org/wiki/Open_CASCADE Open CASCADE Technology] tools and structure is used in FreeCAD
 +
* [[Topological data scripting|Topological data scripting]]: How to interact with the Part Module
 +
* [[PythonOCC|PythonOCC]]: How to unleash the whole Open CASCADE power
 +
* [[Mesh to Part|Mesh to Part]]: Converting between object types
 +
 
 +
====Accessing the Coin scenegraph==== <!--T:11-->
 
* [[Scenegraph|The Coin/Inventor scenegraph]]: How the FreeCAD scene representation works
 
* [[Scenegraph|The Coin/Inventor scenegraph]]: How the FreeCAD scene representation works
* [[Pivy]]: How to access and modify the scenegraph
+
* [[Pivy|Pivy]]: How to access and modify the scenegraph
 +
 
 +
===Controlling the Qt interface=== <!--T:12-->
 +
* [[PySide|PySide]]: How to access the interface, and modify its contents
 +
* [[Embedding FreeCADGui|Using the FreeCAD GUI]] in another Qt application with PyQt
  
'''Controlling the Qt interface'''
+
===Working with parametric objects=== <!--T:13-->
* [[PyQt]]: How to access the interface, and modify its contents
 
* [[Embedding FreeCADGui|Using the FreeCAD GUI]] in another Qt application wity PyQt
 
  
'''Working with parametric objects'''
+
<!--T:35-->
* [[Scripted objects]]: How to make 100% python-scripted objects in FreeCAD
+
* [[Scripted_objects|Scripted objects]]: how to make 100% Python-scripted objects.
* [[Drawing Module]]: Automating the 3D-to-2D process
+
** [[Scripted_objects_with_attachment|Scripted objects with attachment]]: how to make scripted objects attachable to other objects.
 +
** [[Scripted_objects_saving_attributes|Scripted objects saving attributes]]: how to save and restore attributes of the proxy class with {{incode|__getstate__}} and {{incode|__setstate__}}.
 +
** [[Scripted_objects_migration|Scripted objects migration]]: how to migrate old scripted objects to a new class.
  
'''Examples'''
+
===Examples=== <!--T:14-->
* [[Code snippets]] : A collection of pieces of FreeCAD python code, to serve as ingredients in your scripts...
+
* [[Code snippets|Code snippets]] : A collection of pieces of FreeCAD Python code, to serve as ingredients in your scripts...
* [[Line drawing function]]: How to build a simple tool to draw lines
+
* [[Line drawing function|Line drawing function]]: How to build a simple tool to draw lines
* [[Dialog creation]]: How to construct dialogs with Qt designer, and use them in FreeCAD
+
* [[Dialog creation|Dialog creation]]: How to construct dialogs with Qt designer, and use them in FreeCAD
* [[Embedding FreeCAD]]: How to import FreeCAD as a python module in other applications
+
* [[Embedding FreeCAD|Embedding FreeCAD]]: How to import FreeCAD as a Python module in other applications
* The [[Draft Module]] adds basic 2d drawing functions to freecad. It is written entirely in python, so it can be a good example if you want to write your own modules.
+
* The [[Draft Module|Draft Module]] adds basic 2d drawing functions to freecad. It is written entirely in Python, so it can be a good example if you want to write your own modules.
* [[FreeCAD vector math library]] : A couple of handy functions to manipulate FreeCAD vectors. This library is also included in the Draft module.
+
* [[FreeCAD vector math library|FreeCAD vector math library]] : A couple of handy functions to manipulate FreeCAD vectors. This library is also included in the Draft module.
  
== API Functions ==
+
== API Functions == <!--T:15-->
  
The complete API description can be found [[:Category:API|here]]. Note that it can be incomplete, since we still didn't find a way to include it automatically on this wiki. For more accurate information, browse the modules directly from FreeCAD.
+
<!--T:16-->
 +
The complete API documentation of FreeCAD is located at http://www.freecadweb.org/api/ . It contains both C++ and Python APIs, and is not totally well formatted yet, which can be confusing when looking for python-only code. An easier to browse version can be found [[:Category:API|here]]. Note that it can be incomplete, since it is updated manually. For more accurate information, browse the modules directly from FreeCAD's Python console.
  
== Advanced modification ==
+
<!--T:34-->
 +
Related: [[Exposing_C%2B%2B_to_Python|Exposing C++ to Python]]
  
* [[Start up and Configuration]]: Startup and command line options
+
== Advanced modification == <!--T:17-->
* [[Install on Windows]]: Using the windows installer
 
* [[CompileOnWindows|Compiling FreeCAD on Windows]] and [[CompileOnUnix|Compiling FreeCAD on Unix]]
 
* [[Branding]]: Simple modifications you can do to the source code to change some aspects of FreeCAD
 
* [[Extra python modules]] : Extend the FreeCAD python interpreter with these powerful modules!
 
  
== Python tutorials ==
+
<!--T:18-->
 +
* [[Start up and Configuration|Start up and Configuration]]: Startup and command line options
 +
* [[Install on Windows|Install on Windows]]: Using the windows installer
 +
* [[Compile_on_Windows|Compiling FreeCAD on Windows]] and [[Compile on Linux/Unix|Compiling FreeCAD on Linux]]
 +
* [[Branding|Branding]]: Simple modifications you can do to the source code to change some aspects of FreeCAD
 +
* [[Extra python modules|Extra python modules]] : Extend the FreeCAD python interpreter with these powerful modules!
  
 +
== Python tutorials == <!--T:19-->
 +
 +
<!--T:20-->
 
These are good generic tutorials, not specific to FreeCAD, that might interest you if you are totally new to python.
 
These are good generic tutorials, not specific to FreeCAD, that might interest you if you are totally new to python.
  
 +
<!--T:21-->
 
'''Python'''
 
'''Python'''
* [http://docs.python.org/tut/tut.html Official python tutorial] - A very complete tutorial for discovering python
+
* [https://docs.python.org/2.7/tutorial/index.html Official python tutorial] - A very complete tutorial for discovering python
 
* [http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python Non-programmer tutorial for python] - an excellent wikibook
 
* [http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python Non-programmer tutorial for python] - an excellent wikibook
 
* [http://npt.cc.rsu.ru/user/wanderer/ODP/Python_for_Newbies.htm Python for newbies] - one big tutorial covering all the basics
 
* [http://npt.cc.rsu.ru/user/wanderer/ODP/Python_for_Newbies.htm Python for newbies] - one big tutorial covering all the basics
  
'''PyQt''' - How to create and manage FreeCAD's Qt UI interface from python
+
<!--T:22-->
 +
'''PySide''' - How to create and manage FreeCAD's Qt UI interface from python
 +
* [http://zetcode.com/gui/pysidetutorial/ PySide tutorial] : A platform-agnostic tutorial showing the usage of PySide with examples
 +
* [http://www.pythoncentral.io/series/python-pyside-pyqt-tutorial/ PySide/PyQt tutorial] : A easy to read tutorial that covers PySide and PyQt with examples
 +
* [http://qt-project.org/wiki/PySideDocumentation PySide documentation] : from the Qt Project (the people who wrote it all)
 +
* [http://qt-project.org/wiki/QtCreator_and_PySide Using QtCreator in PySide] : also from the Qt Project
 +
* [http://srinikom.github.io/pyside-docs/index.html PySide reference] : endless detail on the minutiae of PySide and Qt, a reliable reference source
 +
* [http://nullege.com/codes/search?cq=PySide PySide code snippets] : a searchable database of PySide code snippets
 +
 
 +
<!--T:31-->
 +
The following two references are PyQt specific (not PySide) but may offer some information of use:
 
* [http://www.cs.usfca.edu/~afedosov/qttut/ Basic PyQt tutorial] : A simple and short linux-based tutorial that will explain how to work with PyQt and Qt Designer
 
* [http://www.cs.usfca.edu/~afedosov/qttut/ Basic PyQt tutorial] : A simple and short linux-based tutorial that will explain how to work with PyQt and Qt Designer
* [http://zetcode.com/tutorials/pyqt4/firstprograms/ First programs in PyQt4] : A platform-agnostic tutorial showing the interns of python + qt
+
* [http://vizzzion.org/?id=pyqt Programming Qt applications in python] : A more in-depth tutorial covering all the process of working with qt and python
* [http://vizzzion.org/?id=pyqt programming Qt applications in python] : A more in-depth tutorial covering all the process of working with qt and python.
 
  
 +
<!--T:23-->
 
'''Pivy''' - How to interact with FreeCAD's 3D scenes
 
'''Pivy''' - How to interact with FreeCAD's 3D scenes
* [http://pivy.coin3d.org/documentation/pycon Basic Pivy tutorial] : A very simple tutorial form the official Pivy site
+
* [http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.108.947&rep=rep1&type=pdf Pivy - Embedding a Dynamic Scripting Language into a Scene Graph Library] : Thesis that explains Pivy in detail
* [http://www.google.com.br/url?sa=U&start=3&q=http://studierstube.icg.tu-graz.ac.at/doc/pdf/PivyStudierstubeTutorial.pdf&ei=XyC1Sc2wOeCKmQem_eHnBQ&usg=AFQjCNEYhb-0DcUc6OxFVijAe1epBb-4aA Introducing Pivy into studiersturbe] : A document that is not really a tutorialbut that illustrates well how Pivy works
+
* [http://ftp.ntua.gr/mirror/python/pycon/dc2004/papers/47/ High Level 3D Graphics Programming in Python] : Pivy example from Pycon 2004
 +
* [https://www.semanticscholar.org/paper/Integrating-Pivy-into-Studierstube-4.2-Gruber/08c9a89c8326c87f81c2d83428029fbfb6c2ae64 Introducing Pivy into studierstube] [https://www.researchgate.net/publication/228737136_Integrating_Pivy_into_Studierstube_42 (Mirror)] : A paper that is not really a tutorial, but that illustrates well how Pivy works (requires an academic account)
  
== Community projects ==  
+
== Community projects == <!--T:24-->
  
On the [[free-cad:Community Portal|Community portal]], you can find other FreeCAD-based projects run by the FreeCAD users community. If you are starting a new FreeCAD project, be sure to list it there! We also have a page with things you can do if you would like to [[Help FreeCAD]].
+
<!--T:25-->
 +
On the [[FreeCAD Community Portal|Community portal]], you can find other FreeCAD-based projects run by the FreeCAD users community. If you are starting a new FreeCAD project, be sure to list it there! We also have a page with things you can do if you would like to [[Help FreeCAD|Help FreeCAD]].
  
{{languages | {{ru|Power users hub/ru}} }}
+
<!--T:38-->
 +
* [[Scientific_literature|Scientific literature]]: articles that reference or use the FreeCAD system in different ways.
  
[[Category:Hubs]]
+
</translate>
[[Category:Poweruser Documentation]]
+
{{Powerdocnavi{{#translation:}}}}
 +
[[Category:Hubs{{#translation:}}]]

Latest revision as of 12:29, 11 October 2020

Other languages:
Bahasa Indonesia • ‎Deutsch • ‎English • ‎Türkçe • ‎español • ‎français • ‎hrvatski • ‎italiano • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎svenska • ‎čeština • ‎русский • ‎中文(中国大陆)‎ • ‎中文(台灣)‎ • ‎한국어

Power user hub.png



This is the place to come if you are an experienced user and want to learn more about customizing and extending FreeCAD.

FreeCAD is extensible by Python code that is run directly in the Python console, or that is loaded from modules at startup. This means that you can modify FreeCAD without needing to recompile the program. For example, you can:

  • Create and modify geometry: you can create a new object type, either from scratch or by adapting an existing type.
  • Create custom tools and commands: add your own set of tools that run your code.
  • Modify the interface: create toolbars to put your tools, create special windows, panels, or interfaces for interacting with your tools.
  • Modify the scenegraph representation: FreeCAD has separate processes for building up the geometry and displaying that geometry on screen. You have full access to the way the scene contents are displayed on screen, therefore you can modify that representation, interact with it, or add custom behaviour to it. You can also add custom screen widgets, like information, draggers, anchors or temporary entities.

If you'd like to contribute content to these pages, request a wiki account with editor permissions in the forum, and read the WikiPages for the general guidelines that you should follow. For other ways to contribute with the project, see the Help FreeCAD page.

Customizing FreeCAD

Scripting in FreeCAD

General

Modules

The functionality of FreeCAD is separated in Modules which deal with special data types and applications. FreeCAD has built-in modules and Extension Modules (plug-ins). Once plugin modules are installed, they become availible to you as easily as the built-in modules. The modules described below are the default modules, includeed in every FreeCAD installation.

  • The Builtin modules are the principal FreeCAD modules. They contain tools for manipulating general FreeCAD configurations, documents and their contents.
  • Workbench creation shows you how to create your own workbench

Working with Meshes

Working with Parts

Accessing the Coin scenegraph

Controlling the Qt interface

Working with parametric objects

Examples

  • Code snippets : A collection of pieces of FreeCAD Python code, to serve as ingredients in your scripts...
  • Line drawing function: How to build a simple tool to draw lines
  • Dialog creation: How to construct dialogs with Qt designer, and use them in FreeCAD
  • Embedding FreeCAD: How to import FreeCAD as a Python module in other applications
  • The Draft Module adds basic 2d drawing functions to freecad. It is written entirely in Python, so it can be a good example if you want to write your own modules.
  • FreeCAD vector math library : A couple of handy functions to manipulate FreeCAD vectors. This library is also included in the Draft module.

API Functions

The complete API documentation of FreeCAD is located at http://www.freecadweb.org/api/ . It contains both C++ and Python APIs, and is not totally well formatted yet, which can be confusing when looking for python-only code. An easier to browse version can be found here. Note that it can be incomplete, since it is updated manually. For more accurate information, browse the modules directly from FreeCAD's Python console.

Related: Exposing C++ to Python

Advanced modification

Python tutorials

These are good generic tutorials, not specific to FreeCAD, that might interest you if you are totally new to python.

Python

PySide - How to create and manage FreeCAD's Qt UI interface from python

The following two references are PyQt specific (not PySide) but may offer some information of use:

Pivy - How to interact with FreeCAD's 3D scenes

Community projects

On the Community portal, you can find other FreeCAD-based projects run by the FreeCAD users community. If you are starting a new FreeCAD project, be sure to list it there! We also have a page with things you can do if you would like to Help FreeCAD.