Std SendToPythonConsole: Difference between revisions

From FreeCAD Documentation
(Revised.)
No edit summary
Line 38: Line 38:
}}
}}
<translate>
<translate>
{{Caption|Example output of the command}}
{{Caption|Example output: an edge of a [[Part_Box|Part Box]] was selected}}


==Usage== <!--T:5-->
==Usage== <!--T:5-->

Revision as of 08:58, 19 March 2020

This documentation is a work in progress. Please don't mark it as translatable since it will change in the next hours and days.


Std SendToPythonConsole

Menu location
Edit → Send to Python Console
Workbenches
All
Default shortcut
Ctrl+Shift+P
Introduced in version
0.19
See also
None

Description

The Std SendToPythonConsole command creates a variable in the Python console referencing a selected object. If a subshape of the object is selected two additional variables are created, one referencing the shape of the object and the other referencing the subshape itself. The variables and the code involved can assist the development of Python code.

>>> ### Begin command Std_SendToPythonConsole
>>> obj = App.getDocument("Unnamed1").getObject("Box")
>>> shp = App.getDocument("Unnamed1").getObject("Box").Shape
>>> elt = App.getDocument("Unnamed1").getObject("Box").Shape.Edge8
>>> ### End command Std_SendToPythonConsole

Example output: an edge of a Part Box was selected

Usage

  1. There are several ways to invoke the command:
    • Select the Edit → Send to Python Console option from the menu.
    • Select the Send to Python Console option from the Tree view context menu or 3D view context menu.
    • Use the keyboard shortcut: Ctrl+Shift+P.