Power users hub: Difference between revisions

From FreeCAD Documentation
m (Removed and updated broken links about Pivy. Added more informative links about Pivy. Removed '.' at end of line for consistency.)
({{TOCright}} to match Developer_hub.)
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{TOCright}}
[[Image:Power_user_hub.png|64px]]
[[Image:Power_user_hub.png|64px]]
----
----
__NOTOC__
<translate>
<translate>


Line 16: Line 16:


<!--T:3-->
<!--T:3-->
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.
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.


== Customizing FreeCAD == <!--T:5-->
== Customizing FreeCAD == <!--T:5-->
Line 29: Line 29:
== Scripting in FreeCAD == <!--T:7-->
== Scripting in FreeCAD == <!--T:7-->


===General=== <!--T:8-->
===General=== <!--T:39-->

* [[Introduction to Python|Introduction to Python]] - See also other Python tutorials at the bottom of this page
<!--T:8-->
* [[Python scripting tutorial|FreeCAD scripting tutorial]] - A general look at python scripting in FreeCAD
* [[Introduction_to_Python|Introduction to Python]] - See also other Python tutorials at the bottom of this page
* [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]]: Well, the basics.
* [[Python_scripting_tutorial|FreeCAD scripting tutorial]] - A general look at python scripting in FreeCAD
* [[Gui Command|Gui Command]]: Adding custom commands to the GUI
* [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]]: Well, the basics.
* [[Gui_Command|Gui Command]]: Adding custom commands to the GUI
* Using mixed [[Units|Units]] in FreeCAD
* Using mixed [[Units|Units]] in FreeCAD
* [[Profiling|Profiling]] the Python code
* [[Profiling|Profiling]] the Python code
* [[Debugging#Python Debugging|Debugging]] the Python code


=== Modules === <!--T:28-->
=== Modules === <!--T:28-->
Line 46: Line 49:
* [[Workbench creation|Workbench creation]] shows you how to create your own workbench
* [[Workbench creation|Workbench creation]] shows you how to create your own workbench


====Working with Meshes==== <!--T:9-->
====Working with Meshes==== <!--T:40-->
* [[Mesh Scripting|Mesh Scripting]]: How to interact with the [[Mesh Module|Mesh Module]]


====Working with Parts==== <!--T:10-->
<!--T:9-->
* [[Mesh Scripting|Mesh Scripting]]: How to interact with the [[Mesh_Workbench|Mesh Workbench]]
* [[Part Module|The Part Module]]: How [http://en.wikipedia.org/wiki/Open_CASCADE Open CASCADE Technology] tools and structure is used in FreeCAD

====Working with Parts==== <!--T:41-->

<!--T:10-->
* [[Part_Workbench|The Part Workbench]]: 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
* [[Topological data scripting|Topological data scripting]]: How to interact with the Part Module
* [[PythonOCC|PythonOCC]]: How to unleash the whole Open CASCADE power
* [[PythonOCC|PythonOCC]]: How to unleash the whole Open CASCADE power
* [[Mesh to Part|Mesh to Part]]: Converting between object types
* [[Mesh to Part|Mesh to Part]]: Converting between object types


====Accessing the Coin scenegraph==== <!--T:11-->
====Accessing the Coin scenegraph==== <!--T:42-->

<!--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|Pivy]]: How to access and modify the scenegraph
* [[Pivy|Pivy]]: How to access and modify the scenegraph


===Controlling the Qt interface=== <!--T:12-->
===Controlling the Qt interface=== <!--T:43-->

<!--T:12-->
* [[PySide|PySide]]: How to access the interface, and modify its contents
* [[PySide|PySide]]: How to access the interface, and modify its contents
* [[Embedding FreeCADGui|Using the FreeCAD GUI]] in another Qt application with PyQt
* [[Embedding FreeCADGui|Using the FreeCAD GUI]] in another Qt application with PyQt
Line 71: Line 82:
** [[Scripted_objects_migration|Scripted objects migration]]: how to migrate old scripted objects to a new class.
** [[Scripted_objects_migration|Scripted objects migration]]: how to migrate old scripted objects to a new class.


===Examples=== <!--T:14-->
===Examples=== <!--T:44-->

<!--T:14-->
* [[Code snippets|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|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|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|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|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_Workbench|Draft Workbench]] 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|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.


Line 90: Line 103:


<!--T:18-->
<!--T:18-->
* [[Start up and Configuration|Start up and Configuration]]: Startup and command line options
* [[Start_up_and_Configuration|Start up and Configuration]]: Startup and command line options
* [[Install on Windows|Install on Windows]]: Using the windows installer
* [[Installing_on_Windows|Installing on Windows]]: Using the windows installer
* [[Compile_on_Windows|Compiling FreeCAD on Windows]] and [[Compile on Linux/Unix|Compiling FreeCAD on Linux]]
* [[Compile_on_Windows|Compiling FreeCAD on Windows]] and [[Compile_on_Linux|Compiling FreeCAD on Linux]]
* [[Branding|Branding]]: Simple modifications you can do to the source code to change some aspects of FreeCAD
* [[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!
* [[Extra_python_modules|Extra python modules]] : Extend the FreeCAD python interpreter with these powerful modules!


== Python tutorials == <!--T:19-->
== Python tutorials == <!--T:19-->
Line 103: Line 116:
<!--T:21-->
<!--T:21-->
'''Python'''
'''Python'''
* [https://docs.python.org/2.7/tutorial/index.html Official python tutorial] - A very complete tutorial for discovering python
* [https://docs.python.org/3/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
* [https://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3 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


Line 134: Line 147:
<!--T:38-->
<!--T:38-->
* [[Scientific_literature|Scientific literature]]: articles that reference or use the FreeCAD system in different ways.
* [[Scientific_literature|Scientific literature]]: articles that reference or use the FreeCAD system in different ways.



</translate>
</translate>

Revision as of 10:01, 28 May 2022


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 Workbench 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.