Std SendToPythonConsole: Difference between revisions

From FreeCAD Documentation
(Fixed GuiCommand.)
(Revised.)
Line 1: Line 1:
<languages/>
<languages/>

{{Page in progress}}

<translate>
<translate>


Line 15: Line 18:
{{GuiCommand
{{GuiCommand
|Name=Std SendToPythonConsole
|Name=Std SendToPythonConsole
|MenuLocation={{StdMenu|[[Std Edit Menu|Edit]]}} → Send to Python Console
|MenuLocation=Edit → Send to Python Console
|Workbenches=All
|Workbenches=All
|Shortcut={{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}}
|Shortcut={{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}}
Line 21: Line 24:
}}
}}


== Description == <!--T:3-->
==Description== <!--T:3-->


<!--T:4-->
<!--T:4-->
This command creates a variable named "'''obj'''" in the FreeCAD Python Console that references the currently selected object. If a subshape of the object is also selected, a "'''shp'''" variable will also be created, referencing the object shape, and an "'''elt'''" variable referencing the selected subshape (edge, face, or vertex)
The '''Std SendToPythonConsole''' command creates a variable in the [[Python_console|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.

</translate>
{{Code|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
}}
<translate>
{{Caption|Example output of the command}}


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


# There are several ways to invoke the command:
==Notes== <!--T:6-->
#* Select the {{MenuCommand|Edit → [[Image:Std_SendToPythonConsole.svg|16px]] Send to Python Console}} option from the menu.

#* Select the {{MenuCommand|[[Image:Std_SendToPythonConsole.svg|16px]] Send to Python Console}} option from the [[Tree_view|Tree view]] context menu or [[3D_view|3D view]] context menu.
==Limitations== <!--T:7-->
#* Use the keyboard shortcut: {{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}}.

==Scripting== <!--T:8-->


<!--T:9-->
<!--T:9-->
Line 44: Line 57:
}}
}}


<!--T:10-->
{{Std Base navi}}

<!--T:11-->
{{Userdocnavi}}
</translate>
</translate>
{{Std Base navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{clear}}
{{clear}}

Revision as of 08:46, 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 of the command

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.