Std Vers la console Python

From FreeCAD Documentation
Revision as of 10:44, 15 April 2020 by David69 (talk | contribs) (Created page with "{{GuiCommand/fr |Name=Std SendToPythonConsole |Name/fr=Std Variable dans Python |MenuLocation=Edition → Send to Python Console |Workbenches=Tous |Shortcut={{KEY|Ctrl}}+{{KEY...")

Std Variable dans Python

Emplacement du menu
Edition → Send to Python Console
Ateliers
Tous
Raccourci par défaut
Ctrl+Shift+P
Introduit dans la version
0.19
Voir aussi
Aucun

Description

La commande Std Variable dans Python crée une variable dans la console Python référençant un objet sélectionné. Si une sous-forme de l'objet est sélectionnée, deux variables supplémentaires sont créées, l'une faisant référence à la forme de l'objet et l'autre faisant référence à la sous-forme elle-même. Les variables et le code impliqués peuvent être utilisés pour développer du code Python.

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

Example output: an edge of a Part Box was selected

Usage

  1. Select a single object.
  2. 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.