Positionierung

From FreeCAD Documentation
Revision as of 08:53, 4 June 2020 by Maker (talk | contribs)

Platzierung ist wie FreeCAD den Standort und die Lage (Orientierung) eines Objekts im Raum angibt. Die Platzierung kann in vielfältigen Formen angegeben und über Skripten, den Eigenschaftenbereich oder den Platzierungsdialog (Bearbeiten Menü) bearbeitet werden.

=Zugriff auf das Platzierungsattribut

Auf die Platzierungsattribute eines Objekts kann auf 3 Arten zugegriffen und verändert werden:

Platzierung im Eigenschaftenpaneel
Skriptplatzierung als y/p/r und Matrix und seine API.
Platzierungsdialog Rotationsachse mit Winkel

Formen der Platzierung

Die Platzierung wird intern als eine Position und eine Rotation (Drehachse und Winkel in ein Quaternion umgewandelt Quaternionen und räumliche Rotation, Quaternionen) gespeichert. Während es mehrere Formen gibt, um eine Rotation festzulegen, z.B. mit einem Rotationszentrum, wird dies nur zur Beeinflussung der Rotationsberechnung verwendet und nicht für spätere Operationen gespeichert. Wenn eine Drehachse von (1,1,1,1) angegeben ist, kann sie ebenfalls normalisiert werden, wenn sie im Quaternion gespeichert ist und als (0.58, 0.58, 0.58, 0.58, 0.58) erscheinen, wenn das Objekt später durchsucht wird.

Winkel, Achse und Position

Platzierung = [Winkel, Achse, Position]

Die erste Form der Platzierung fixiert die Position eines Objekts im Raum und beschreibt seine Ausrichtung als eine einzige Drehung um eine Achse.

Winkel = r ist ein Skalar, der den Grad der Drehung des Objekts um die Achse anzeigt. Wird zwar als Grad eingegeben, wird aber intern als Bogenmaß gespeichert.

Achse = (ax,ay,az) ist ein Vektor, der eine Drehachse beschreibt (siehe Hinweis zur Drehachse). Beispiele sind:

   (1,0,0,0) ==> um die X-Achse.
   (0,1,0) ==> um die Y-Achse.
   (0,0,1) ==> um die Z-Achse
   (0.71,0.71,71,0) ==> um die Linie y=x.

Beachte, dass es auch möglich ist, ein Objekt entlang dieser Drehachse (Axialbewegung) zu verschieben (bewegen), indem Du den Bewegungsabstand in der Axialspinbox eingibst und auf die Schaltfläche Apply axial klickst. (Eine Möglichkeit, sich eine axiale Bewegung vorzustellen, ist, an ein Flugzeug zu denken, bei dem sich ein Propeller auf der Nase dreht - der Propeller dreht sich um eine Drehachse, während sich das Flugzeug entlang derselben Achse bewegt.) Die Werte im Vektor können als die relative Bewegungsgröße betrachtet werden, die in dieser Richtung angewendet wird. So wird beispielsweise im Fall y=x (0.71,0.71,71,0) der in der Axialspinbox enthaltene Wert gleichermaßen auf die X- und Y-Richtung angewendet, aber es findet keine Bewegung in der Z-Richtung statt.

Position = (x,y,z) ist ein Vektor, der den Punkt beschreibt, von dem aus die Geometrie des Objekts berechnet wird (in Wirklichkeit ein "lokaler Ursprung" für das Objekt). Beachten Sie, dass in Skripten Placement.Base verwendet wird, um die Positionskomponente einer Platzierung zu bezeichnen. Der Eigenschaftseditor ruft diesen Wert "Position" und der Positionierungsdialog nennt ihn "Translation".

Position und Gieren, Neigen und Rollen

Positionierungsdialog Euler Winkel

Positionierung = [Position, Gieren-Neigen-Rollen]

Die zweite Form der Positionierung fixiert die Position eines Objekts im Raum mit einer Position (wie in der ersten Form), beschreibt aber seine Ausrichtung mit den Winkeln Gieren, Neigen und Rollen (Gieren, Neigen, Rollen). Diese Winkel werden manchmal als Euler-Winkel oder Tait-Bryan-Winkel bezeichnet (Euler-Winkel). Gieren, Neigen und Rollen sind gängige Luftfahrtbegriffe für die Orientierung (oder Haltung) eines Körpers.

Position = (x,y,z) ist ein Vektor, der den Punkt beschreibt, von dem aus die Geometrie des Objekts berechnet wird (in Wirklichkeit ein "lokaler Ursprung" für das Objekt).

Yaw-Pitch-Roll = (y,p,r) ist ein Tupel, das die Position des Objekts angibt. Die Werte für y,p,r geben den Grad der Drehung um jede der z,y,x-Achsen an (siehe Hinweis).

>>> App.getDocument("Name_des_Dokuments").Cylinder.Placement=App.Placement(App.Vector(0,0,0,0), App.Rotation(10,20,30), App.Vector(0,0,0))

App.Rotation(10,20,30) = Euler Winkel

Gieren = 10 Grad (Z)

Neigung = 20 Grad (Y)

Rollen = 30 Grad (X)


Yaw ist die Drehung um die Z-Achse, d.h. eine Drehung von links nach rechts.
(Der Gierwinkel wird Psi ψ genannt).

Pitch ist die Rotation um die Y Achse, man kann sagen, die Nase hoch und runter.
(Der Neigungswinkel wird Phi φ genannt).

Roll ist die Rotation um die X Achse, man sagt über die Flügel rollen.
(Der Rollwinkel wird Thêta θ genannt).

Matrix

Positionierung = Matrix

Die dritte Form der Positionierung beschreibt die Position und Orientierung des Objektes mit einer 4 mal 4 Transformationsmatrix (Affine Abbildung).

Matrix =

  ((r11,r12,r13,t1),
   (r21,r22,r23,t2),
   (r31,r32,r33,t3),
   (0,0,0,1)) , wobei rij die Rotation und ti die Verschiebung angibt. 

Der Platzierungsdialog=

Der Platzierungsdialog wird über das Menü Bearbeiten aufgerufen. Er wird zum präzisen Drehen/Übersetzen von Objekten verwendet. Er wird auch verwendet, wenn wir eine Skizze auf einer "Nicht Standard" Ebene erstellen oder die Ausrichtung einer Skizze auf eine neue Ebene ändern müssen.

Der Abschnitt Schiebung passt die Position des Objekts im Raum an. Der Abschnitt Mitte passt die Rotationsachse an eine Achse an, die nicht durch den Referenzpunkt des Objekts verläuft. Der Abschnitt Rotation stellt den/die Rotationswinkel und die Methode zur Angabe dieser Winkel ein.

But while the elements within each section generally apply to the purpose of that section there are also some elements in one section that can affect elements in another section. For example, clicking the Selected points button in the Center section with 2 points selected in the 3d view results in not only populating the Center coordinate spinboxes with the coordinates of the midpoint between those 2 selected points, but it also creates a custom axis along the line defined by those 2 selected points in the Rotation section. In another example, placing a value in the Axial spinbox and clicking the Apply axial button in the Translation section translates (moves) the object along the axis defined in the Rotation section.

The Apply incremental changes to object placement tick box is useful when translations/rotations are to be made relative the object's current position/attitude, rather than to the original position/attitude. Ticking this box resets the dialogue input fields to zero, but does not change the object's orientation or location. Subsequent entries do change the orientation/location, but are applied from the object's current position. Enabling this checkbox is also useful when using the Selected points button as it can sometimes prevent undesired placement changes.

PS: since version 0.17 introduce new object Part, this object have his placement, and the Placement object created in the Part object is incremented with the Part Placement. introduced in version 0.17 For obtain the Part Placement use this code

import Draft, Part
sel = FreeCADGui.Selection.getSelection()
print sel[0].Placement
print sel[0].getGlobalPlacement()   # return the GlobalPlacement
print sel[0].getParentGeoFeatureGroup() # return the GeoFeatureGroup, ex:  Body or a Part.
print  "____________________"

Selected points button is used to populate the coordinates in the Center coordinates spinboxes and (when 2 or 3 points are selected) additionally to create a custom (user-defined) axis of rotation in the Rotation section. A point can be a vertex, but it can also be any point along an edge or on a face. When you select an edge or face the entire edge or face is selected, but FreeCAD also remembers which point on that face or edge the mouse pointer was hovering over when that edge or face was selected. It is this point's coordinates that get used in the Placement dialog when the Selected points button is clicked. You might be thinking this isn't a very precise way of selecting a point, and you are correct, but in many cases it is sufficient that the point selected is guaranteed to be on that edge or face. In cases where you need to precisely designate a point to be used you should select a vertex. When there is no vertex in the desired location consider creating one, perhaps in a temporary sketch attached to that face or edge, perhaps using a Draft workbench object, such as a line or point, etc.

Let us first consider the simple case of selecting 1 point. The workflow is to first select the desired point, then click the Selected points button. The coordinates of the selected point will be used to populate the X, Y, and Z spinboxes within the Center section. Now any rotation done on the object will about this center of rotation.

Now consider the case of selecting 2 points. You would select the 2 desired points, and then click the Selected points button. The coordinates of the midpoint between the 2 selected points get placed into the X, Y, and Z spinboxes within the Center section. Now any rotation done on the object will be about this center of rotation. But in addition to setting up the Center section coordinates a custom (user-defined) axis is also added to the Axis element within the Rotation section. (Note: if you were in Euler rotation mode, the mode gets switched to Rotation with an axis mode and the new custom axis is selected as the current axis of rotation.) Now any rotation done using the new custom axis will be about this axis of rotation. As an added bonus, the distance is measured between the 2 selected points, and this information is given in the Report View. (Note: Hold down the Shift key while clicking the Selected points button to copy the distance measurement to the clipboard.) By entering this distance into the Axial spinbox in the Translation section and clicking the Apply axial button you can translate (move) the object so that the first selected point now occupies the coordinates occupied by the second selected point (at the time the Selected points button was clicked).

Now consider the case of selecting 3 points. You would select the 3 desired points, and then click the Selected points button. The coordinates of the first selected point (order of selection is very important here) get placed into the X, Y, and Z spinboxes within the Center section. Since 3 points define a plane FreeCAD is able to take advantage of that and use those 3 points to create a new custom (user-defined) axis of rotation that is normal (perpendicular) to that defined plane. As with 2 selected points, the distance between points is also shown in the Report View, but this time it is the distance between the 2nd and 3rd selected points. (Note: Hold down the Shift key while clicking Selected points button -- Shift + Click -- to copy the angle measurement to the clipboard.) Additionally, the angle between the 2nd and 3rd points is also measured and displayed in the Report View. By entering this angle into the Angle spinbox within the Rotation section we can very precisely rotate the object such that now the 2nd selected point is in alignment with the coordinates occupied by the 3rd selected point. (Note: you might want to increase the number of digits used within the Edit menu -> Preferences -> General -> Units -> Number of decimals spinbox if you desire more precision.)

Beispiele

Rotationen um eine einzelne Achse:

Before Rotation
Before Rotation

Vor der Rotation (Draufsicht)

After Rotation about Z
After Rotation about Z

Nach der Rotation um Z (Draufsicht)

After Rotation about y=x
After Rotation about y=x

Nach der Rotation um y=x (Ansicht von rechts)

Rotation mit versetztem Zentrum:

Before Rotation
Before Rotation

Vor der Rotation (Draufsicht)

After Rotation about Z
After Rotation about Z

Nach der Rotation um Z (Draufsicht)

Rotation mit Euler-Winkeln:

Before Rotation
Before Rotation

Vor der Rotation

After Rotation
After Rotation

Nach der Rotation

Placement.Base verglichen mit Shape Definition

Positionierung ist nicht der einzige Weg, eine Form im Raum zu positionieren. Siehe die Python Konsole in diesem Bild:

2 Shapes with Same Placement

Beide Würfel haben den selben Wert zur Positionierung, befinden sich aber an verschiedenen Orten! Das geschieht, weil die beiden Formen (Shapes) durch unterschiedliche Punkte (Kurven komplexeren Formen) bestimmt werden. Zu den beiden Formen in der Illustration oben:

 >>> ev = App.ActiveDocument.Extrude.Shape.Vertexes
 >>> for v in ev: print v.X,",",v.Y,",",v.Z
 ... 
 30.0,30.0,0.0
 30.0,30.0,10.0
 40.0,30.0,0.0
 40.0,30.0,10.0
 40.0,40.0,0.0
 40.0,40.0,10.0
 30.0,40.0,0.0
 30.0,40.0,10.0
 >>> e1v = App.ActiveDocument.Extrude001.Shape.Vertexes
 >>> for v in e1v: print v.X,",",v.Y,",",v.Z
 ... 
 0.0,10.0,0.0
 0.0,10.0,10.0
 10.0,10.0,0.0
 10.0,10.0,10.0
 10.0,0.0,0.0
 10.0,0.0,10.0
 0.0,0.0,0.0
 0.0,0.0,10.0
 >>> 
 

Die Punkte (oder Vektoren), die die Form bestimmen verwenden das "Placement.Base"-Attribut als deren Ursprung. Wenn also eine Form um 10 Einheiten an der X-Achse entlang bewegt werden sollen, wird 10 zu den X-Werten aller Punkte addiert oder "Placement.Base" wird auf (10,0,0) gesetzt.

Verwendung von "Center" zur Steuerung der Rotationsachse

Per Vorgabe ist die Rotationsachse nicht eine x-, y- oder z-Achse. Sie ist eine Gerade parallel zur ausgewählten Achse, die durch den Referenzpunkt (Placement.Base) des Objektes läuft, das rotiert werden soll. Das kann mit dem Zentrumsfeld (center) im Positonierungsdialogfenster oder in einem Skript mit dem Zentrumsparameter (center parameter) des FreeCad.Placement Konstrukteurs geändert werden.

Beispiel: eine Schachtel (siehe unten), die auf (20,20,10) positioniert ist.

Before Rotation

Die Schachtel soll um ihre eigene vertikale Zentrumsachse drehen (hier ihre z-Achse), während sie in der gleichen Position bleibt. Dazu wird ein Zentrumswert angegeben, der den Koordinaten (25,25,15) des Zentrums der Schachtel entspricht.

After Rotation

In einem Skript stünde:

import FreeCAD
obj = App.ActiveDocument.Box                       # our box
rot = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),45)   # 45° about Z
#rot = FreeCAD.Rotation(FreeCAD.Vector(1,0,1),45)   # 45° about X and 45° about Z
#rot = FreeCAD.Rotation(10,20,30)                   # here example with Euler angle Yaw = 10 degrees (Z), Pitch = 20 degrees (Y), Roll = 30 degrees (X) 
centre = FreeCAD.Vector(25,25,15)                  # central point of box 
pos = obj.Placement.Base                           # position point of box
newplace = FreeCAD.Placement(pos,rot,centre)       # make a new Placement object
obj.Placement = newplace                           # spin the box

Das selbe Skript mit der Beispieldatei RotateCoG2.fcstd (Diskussion im Forum)

import FreeCAD
obj = App.ActiveDocument.Extrude                    # our box
rot = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),45)    # 45 about Z
#rot = FreeCAD.Rotation(FreeCAD.Vector(1,0,1),45)    # 45° about X and 45° about Z
#rot = FreeCAD.Rotation(10,20,30)                    # here example with Euler angle Yaw = 10 degrees (Z), Pitch = 20 degrees (Y), Roll = 30 degrees (X) 
centre = FreeCAD.Vector(25,25,0)                    # "centre" of rotation (where local Z cuts XY)
pos = obj.Placement.Base                            # original placement of obj
newplace = FreeCAD.Placement(pos,rot,centre)        # make a new Placement object
obj.Placement = newplace                            # spin the box

Hinweise

  • Achse und Winkel können auch als Quaternionen ausgedrückt werden.
  • Der Referenzpunkt eines Objektes ändert sich, abhängit vom Objekt selbst. Beispiele allgemeiner Objekte:
Objekt Referenzpunkt
Part.Box linker (minx), vorderer (miny), unterer (minz) Scheitelpunkt
Part.Sphere Mittelpunkt der Kugel (d.h. Zentrum des Begrenzungskastens)
Part.Cylinder Mitte der unteren Fläche
Part.Cone Mitte der unteren Fläche (oder Scheitelpunkt, wenn der untere Radius 0 ist)
Part.Torus Zentrum eines Torus
Von Skizzen abgeleitete Merkmale das Merkmal erbt die Position der zugrundeliegenden Skizze. Skizzen beginnen immer mit der Position = (0,0,0). Diese Position entspricht dem Ursprung in der Skizze.

Probleme

  • Ab Version 0.13 wurde die Aktualisierung der Positionierungseigenschaften auf der Registerkarte Daten für Objekte deaktiviert, die mit PartDesign erstellt wurden, mit Ausnahme der ersten Skizze, aus der das Solid erstellt wird. Daher kann die Positionierung eines Solids, das in PartDesign aus einer Skizze erstellt wurde, nur geändert werden, indem die Positionierungsparameter der ursprünglichen Konstruktionsskizze (der ersten Skizze), aus der das Solid erstellt wurde, angepasst werden.
  • Die Funktion der Positionierung wird eventuell im Arbeitsbereich Zusammenbau behandelt.

Weiteres

  • Das Tutorial: Flugzeug deckt die Vorghensweise der Positionierung eines Objekts umfassend ab.
  • Eine Schritt-für-Schritt-Erklärung des Positionierungsdialogs finden Sie hier Tasks_Placement.