Std SendToPythonConsole/de: Difference between revisions

From FreeCAD Documentation
(Created page with "{{GuiCommand/de |Name=Std SendeAnPythonKonsole |MenuLocation=Bearbeiten → Sende an Python Konsole |Workbenches=Alle |Shortcut={{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}} |Version=0...")
(Updating to match new version of source page)
 
(24 intermediate revisions by 5 users not shown)
Line 2: Line 2:


{{Docnav/de
{{Docnav/de
|[[Std_Delete|Std Löschen]]
|[[Std_Delete/de|Löschen]]
|[[Std_Placement|Std Platzierung]]
|[[Std_Placement/de|Positionierung]]
|[[Std_Edit_Menu|Std Bearbeitungsmenü]]
|[[Std_Edit_Menu/de|Std Menü Bearbeiten]]
|IconL=Std_Delete.svg
|IconL=Std_Delete.svg
|IconR=Std_Placement.svg
|IconC=Freecad.svg
|IconC=Freecad.svg
|IconR=Std_Alignment.png
}}
}}


{{GuiCommand/de
{{GuiCommand/de
|Name=Std SendeAnPythonKonsole
|Name=Std SendToPythonConsole
|Name/de=Std AnPythonKonsoleSenden
|MenuLocation=Bearbeiten → Sende an Python Konsole
|MenuLocation=Bearbeiten → An Python-Konsole senden
|Workbenches=Alle
|Workbenches=Alle
|Shortcut={{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}}
|Shortcut={{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}}
Line 18: Line 19:
}}
}}


==Description==
==Beschreibung==


Der Befehl '''Std AnPythonKonsoleSenden''' erstellt Variablen in der [[Python_console/de|Python-Konsole]], die auf ein ausgewähltes Objekt und auf seine ausgewählten Teilformen verweisen, zusammen mit ein paar nützlichen anderen Referenzen. Die Variablen und der dazugehörige Kode können zur Entwicklung von Python-Skripten verwendet werden.
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 be used to development Python code.


Abhängig von dem ausgewählten Objekt und seiner ausgewählten Teilformen, falls vorhanden, werden die folgenden Variablen erstellt:
{{Code|code=

>>> ### Begin command Std_SendToPythonConsole
{| class="wikitable"
>>> obj = App.getDocument("Unnamed").getObject("Box")
|-
>>> shp = App.getDocument("Unnamed").getObject("Box").Shape
! Variable name !! Referenced object(s)
>>> elt = App.getDocument("Unnamed").getObject("Box").Shape.Edge8
|-
>>> ### End command Std_SendToPythonConsole
| {{Incode|doc}} || The document containing the selected object
}}
|-
{{Caption|Example output: an edge of a [[Part_Box|Part Box]] was selected}}
| {{Incode|lnk}} || The selected Link object (only created if the selected object is a Link)
|-
| {{Incode|obj}} || Depending on the selected object:<br>
The selected object itself (if the selected object is not a Link)<br>
The Linked object (if the selected object is a Link)<br>
|-
| {{Incode|shp}} || Depending on the type of {{Incode|obj}}:<br>
The {{Incode|Shape}} property of {{Incode|obj}} (for objects derived from the {{Incode|Part::Feature}} class)<br>
The {{Incode|Mesh}} property of {{Incode|obj}} (for Mesh objects)<br>
The {{Incode|Points}} property of {{Incode|obj}} (for Points objects)
|-
| {{Incode|sub}} || The first selected subshape (only created if at least one subshape is selected)
|-
| {{Incode|subs}} || A list containing all subshapes (only created if two or more subshapes are selected)
|}

>>> ### Begin command Std_SendToPythonConsole
>>> try:
>>> del(doc,lnk,obj,shp,sub,subs)
>>> except Exception:
>>> pass
>>>
>>> doc = App.getDocument("Unnamed")
>>> lnk = doc.getObject("Link")
>>> obj = lnk.getLinkedObject()
>>> shp = obj.Shape
>>> sub = obj.getSubObject("Edge10")
>>> subs = [obj.getSubObject("Edge10"),obj.getSubObject("Face3"),obj.getSubObject("Vertex5"),]
>>> ### End command Std_SendToPythonConsole
{{Caption|Beispielausgabe: eine Kante, eine Fläche und ein Eckpunkt eines [[Part_Box/de|Part Würfels]] wurden ausgewählt}}

==Verwendung==

# Ein einzelnes Objekt oder eine bzw. mehrere Teilformen, die zu einem einzelnen Objekt gehören, auswählen.
# Es gibt mehrere Möglichkeiten den Befehl aufzurufen:
#* Den Menüeintrag {{MenuCommand|Bearbeiten → [[Image:Std_SendToPythonConsole.svg|16px]] An Python-Konsole senden}} auswählen.
#* Den Menüeintrag {{MenuCommand|[[Image:Std_SendToPythonConsole.svg|16px]] An Python-Konsole senden}} aus dem Kontextmenü der [[Tree_view/de|Baumansicht]] oder dem Kontextmenü der [[3D_view/de|3D-Ansicht]] auswählen.
#* Das Tastaturkürzel {{KEY|Strg}}+{{KEY|Shift}}+{{KEY|P}}.
# Falls erforderlich öffnet sich die [[Python_console/de|Python-Konsole]].
# Die [[Python_console/de|Python-Konsole]] erhält den Fokus der Tastatur.

==Hinweise==

* Jedes Mal, wenn der Befehl ausgeführt wird, werden alle vorher erzeugten Variablen gelöscht.

* If the selected object is a Link ({{Incode|App::Link}}) and the Linked object is derived from the {{Incode|Part::Feature}} class, the {{Incode|shp}} variable will be the shape of the Linked object. If the Link has been transformed or scaled and you want to access the scaled/transformed shape, you can do so with this code:


: {{Code|code=lnk_shp = Part.getShape(lnk)}}
==Usage==


# Select a single object.
# There are several ways to invoke the command:
#* 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.
#* Use the keyboard shortcut: {{KEY|Ctrl}}+{{KEY|Shift}}+{{KEY|P}}.


{{Docnav
{{Docnav/de
|[[Std_Delete|Std Delete]]
|[[Std_Delete/de|Löschen]]
|[[Std_Placement|Std Placement]]
|[[Std_Placement/de|Positionierung]]
|[[Std_Edit_Menu|Std Edit Menu]]
|[[Std_Edit_Menu/de|Std Menü Bearbeiten]]
|IconL=Std_Delete.svg
|IconL=Std_Delete.svg
|IconR=Std_Placement.svg
|IconR=Std_Placement.svg

Latest revision as of 09:17, 17 April 2022

Std AnPythonKonsoleSenden

Menüeintrag
Bearbeiten → An Python-Konsole senden
Arbeitsbereich
Alle
Standardtastenkürzel
Ctrl+Shift+P
Eingeführt in Version
0.19
Siehe auch
Keiner

Beschreibung

Der Befehl Std AnPythonKonsoleSenden erstellt Variablen in der Python-Konsole, die auf ein ausgewähltes Objekt und auf seine ausgewählten Teilformen verweisen, zusammen mit ein paar nützlichen anderen Referenzen. Die Variablen und der dazugehörige Kode können zur Entwicklung von Python-Skripten verwendet werden.

Abhängig von dem ausgewählten Objekt und seiner ausgewählten Teilformen, falls vorhanden, werden die folgenden Variablen erstellt:

Variable name Referenced object(s)
doc The document containing the selected object
lnk The selected Link object (only created if the selected object is a Link)
obj Depending on the selected object:

The selected object itself (if the selected object is not a Link)
The Linked object (if the selected object is a Link)

shp Depending on the type of obj:

The Shape property of obj (for objects derived from the Part::Feature class)
The Mesh property of obj (for Mesh objects)
The Points property of obj (for Points objects)

sub The first selected subshape (only created if at least one subshape is selected)
subs A list containing all subshapes (only created if two or more subshapes are selected)
>>> ### Begin command Std_SendToPythonConsole
>>> try:
>>>     del(doc,lnk,obj,shp,sub,subs)
>>> except Exception:
>>>     pass
>>> 
>>> doc = App.getDocument("Unnamed")
>>> lnk = doc.getObject("Link")
>>> obj = lnk.getLinkedObject()
>>> shp = obj.Shape
>>> sub = obj.getSubObject("Edge10")
>>> subs = [obj.getSubObject("Edge10"),obj.getSubObject("Face3"),obj.getSubObject("Vertex5"),]
>>> ### End command Std_SendToPythonConsole

Beispielausgabe: eine Kante, eine Fläche und ein Eckpunkt eines Part Würfels wurden ausgewählt

Verwendung

  1. Ein einzelnes Objekt oder eine bzw. mehrere Teilformen, die zu einem einzelnen Objekt gehören, auswählen.
  2. Es gibt mehrere Möglichkeiten den Befehl aufzurufen:
    • Den Menüeintrag Bearbeiten → An Python-Konsole senden auswählen.
    • Den Menüeintrag An Python-Konsole senden aus dem Kontextmenü der Baumansicht oder dem Kontextmenü der 3D-Ansicht auswählen.
    • Das Tastaturkürzel Strg+Shift+P.
  3. Falls erforderlich öffnet sich die Python-Konsole.
  4. Die Python-Konsole erhält den Fokus der Tastatur.

Hinweise

  • Jedes Mal, wenn der Befehl ausgeführt wird, werden alle vorher erzeugten Variablen gelöscht.
  • If the selected object is a Link (App::Link) and the Linked object is derived from the Part::Feature class, the shp variable will be the shape of the Linked object. If the Link has been transformed or scaled and you want to access the scaled/transformed shape, you can do so with this code:
lnk_shp = Part.getShape(lnk)