Placement

From FreeCAD Documentation
Revision as of 17:08, 6 May 2021 by FuzzyBot (talk | contribs) (Updating to match new version of source page)

Introducción

nota de traducción: en esta página pretendemos mantener la siguiente correspondencia entre términos ingles-español

placement emplazamiento

attitude orientación

position posición

Hasta la etapa final de aceptación de la traducción no sustituiremos los términos originales en inglés por sus equivalentes en español.


Placement es el modo en que FreeCAD especifica la position y la attitude (orientacion) de un objeto en el espacio. Placement puede ser especificado de varias formas y manipulado a través de scripting, el panel de Propiedades o el diálogo Placement (Edit menu).


Accediendo al Atributo Placement (emplazamiento)

El atributo Placement (emplazamiento) de un objeto puede ser visto y modificado de 3 maneras:

Placement (emplazamiento) en el panel de Propiedades
Scripting Placement as y/p/r and Matrix and its API.
Placement task panel
Placement Dialog

Formas de definir Placement

Angulo, Eje y Posición

Placement = [Angle, Axis, Position]

Angle, Axis and Position

Placement = [Angle, Axis, Position]

The primera forma de Placement define la situación de un objeto en el espacio con una Position, y describe su orientacion como una simple rotación alrededor de un eje.

Angle = r es un número que indica la magnitud de la rotación del objeto alrededor del eje. Se introduce en grados sexagesimales, pero internamente se almacena en radianes.

Axis = (ax,ay,az) is a vector describing an axis of rotation (See Note about axis of rotation). Examples are:

   (1,0,0)       ==> about X axis
   (0,1,0)       ==> about Y axis
   (0,0,1)       ==> about Z axis
   (0.71,0.71,0) ==> about the line y=x

Note that it is also possible to translate (move) an object along this axis of rotation (axial motion) by entering the distance to move in the Axial: 0.0mm spinbox and clicking Apply axial. (One way to envision axial motion is to think of an airplane with a propeller spinning on its nose -- the propeller spins about an axis of rotation while the plane moves along that same axis.) The values in the vector can be thought of as the relative amount of motion that will be applied in that direction. For example, in the y=x case (0.71,0.71,0) the value contained in the Axial spinbox gets applied in equal measure to the X and Y directions, but no movement happens in the Z direction.

Position = (x,y,z) is a Vector describing the point from which the object's geometry will be calculated (in effect, a "local origin" for the object). Note that in scripts, Placement.Base is used to denote the Position component of a placement. The property editor calls this value Position and the Placement task panel calls it Translation.

Axis = (ax,ay,az) es un vector que describe el eje de rotación (ver Nota sobre eje de rotación). Ejemplos:

   (1,0,0)       ==> giro respecto al eje X
   (0,1,0)       ==> giro respecto al eje Y 
   (0,0,1)       ==> giro respecto al eje Z 
   (0.71,0.71,0) ==> giro respecto a la recta y=x , z=0
                                        

Position = (x,y,z) es un Vector que describe en coordenadas globales el punto (base) de referencia del objeto. Note que en los scripts, Placement.Base se usa para indicar la componente Position de un placement. En el editor de propiedades, a ese valor se le llama "Position".


Position y (rumbo, asiento y escora) (Yaw, Pitch and Roll)

Placement = [Position, Yaw-Pitch-Roll]

La segunda forma de Placement define la localización de un objeto en el espacio con una Position (como en la forma primera), pero describe su orientacion usando los ángulos de rumbo, asiento y escora (Yaw, Pitch and Roll) (Yaw, Pitch, Roll). A esto ángulos también se los denomina ángulos de Euler o de Tait-Bryan(Euler angles). Yaw, Pitch and Roll son términos usados en aviación (y navegación) para indicar la orientación (o attitude) de un cuerpo.

Position = (x,y,z) es un Vector que describe las coordenadas globales del punto de referencia del objeto.

Yaw-Pitch-Roll = (y,p,r) es una terna o tripleta que especifica la attitude del objeto. Los valores de y,p,r indican grados sexagesimales de rotación respecto a cada uno de los ejes del sistema de referencia z,y,x (ver nota).

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

Yaw = 10 degrees (Z)

Pitch = 20 degrees (Y)

Roll = 30 degrees (X)


Yaw is the rotation about the Z axis, that is to say a rotation from left to right.
(The yaw angle is the Psi ψ).

Pitch is rotation about the Y axis, that is to say nose-up and nose-down.
(The Pitch angle is the Phi φ).

Roll is rotation about the X axis, that is to say wing up and down.
(The Roll angle is the Thêta θ).

Matrix

Placement = Matrix

La tercera forma de Placement define la posición y orientación de un objeto en el espacio con una matriz de dimensiones 4x4 que representa una transformación afín (Affine Transformation).

Matrix =

  ((r11,r12,r13,t1),
   (r21,r22,r23,t2),
   (r31,r32,r33,t3),
   (0,0,0,1)) , with rij specifying rotation and ti specifying translation. 
  ((r11,r12,r13,t1),
   (r21,r22,r23,t2),
   (r31,r32,r33,t3),
   (0,0,0,1)) , donde rij indican rotación y ti indican translación.


El diálogo Placement

The Placement Dialog es llamado desde el menu Edit. Se usa para rotar/trasladar los objetos con precisión. Tambien se usa cuando necesitamos crear un sketch (croquis) en un plano "no standard" o cambiar la orientación del plano del croquis a otro plano.

La sección Translation ajusta la localización del objeto en el espacio. La sección Center ajusta el eje de rotación a uno que no pasa por el punto de referencia del objeto. La sección Rotation ajusta el ángulo (o ángulos) de rotación, y el modo de especificar esos ángulos.

Marcar la casilla de selección aplica cambios incrementales sobre el placement (emplazamiento) del objeto es útil cuando las translations/rotations han de ser hechas respecto a las position/attitude actuales del objeto, en lugar de las position/attitude originales. Marcando esa casilla se resetea a cero los campos de entrada del cuadro de diálogo, aunque no cambia la orientation or location del objeto. Datos introducidos posteriormente cambian la orientation/location, pero se aplican a la posición actual del objeto.


Ejemplos

Rotations alrededor de un solo eje:

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.)

Examples

Rotations about a single axis:

Before Rotation
Before Rotation

Antes de la Rotation (visto desde arriba)

After Rotation about Z
After Rotation about Z

Después de Rotation respecto a Z (top view)

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

Después de Rotation respecto a y=x (vista desde la derecha)


Rotation con centro de giro desplazado:

Before Rotation
Before Rotation

antes de la Rotation (top view)

After Rotation about Z
After Rotation about Z

Después de Rotation respecto a Z (vista en planta)


Rotation usando ángulos de Euler:

Before Rotation
Before Rotation

Antes Rotation

After Rotation
After Rotation

Despues Rotation


Placement.Base vs Shape Definition

Placement no es la única manera de definir la posición de una forma en el espacio. Observa la consola de Python en esta imagen:

2 Shapes with Same Placement

Los 2 cubos tienen el mismo valor de Placement, pero están en diferentes locations! Esto es así porque las 2 formas están definidas por vértices diferentes. Para las 2 formas de la ilustración superior:

 >>> 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
 >>> 
 

Los Vértices (or Vectors) que define la forma usan el atributo Placement.Base como su origen. Así, si quieres mover una forma 10 unidades a lo largo del eje X, puedes añadir 10 a la coordenada X de todos los Vértices o, alternativamente, puedes establecer Placement.Position a (10,0,0).


Usar "Center" para controlar el eje de rotación

Por defecto, el eje de rotación no es realmente el eje x/y/z. Es una linea paralela al eje seleccionado, pero pasando por el punto de referencia (Placement.Base) del objeto que va a ser rotado. Ese comportamiento puede ser cambiado usando los campos Center en el diálogo Placement o, en scripts, usando el parámetro Center del constructor FreeCAD.Placement .

Por ejemplo, supongamos que tenemos un bloque (ver ilustración debajo) en las coordenadas (20,20,10).

Before Rotation

Queremos girarlo sobre su propio eje vertical (es decir el eje Z "local"), pero manteniéndolo en el mismo lugar. Podemos conseguirlo facilmente indicando como valor de Center las coordenadas del punto central del bloque, que son (25,25,15).

After Rotation

En un script, haríamos así:

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

Same script with the file example RotateCoG2.fcstd (discussion on the 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

Using Placement in expressions

In expressions it is possible to use the components of the placement for example to access the x-component of the object labeled "Cube":

<<Cube>>.Placement.Base.x

You can also use the whole Placement in a single expression: Right click on Placement property in the property editor, select "show all" then extra properties will show. If you then right click on Placement again the context menu will include Expression, select Expression then the Expression dialogue will open and whatever you type will go into the Placement property rather than its child properties.

To make the placement of "Sketch" equal to that of "Cylinder", you would enter in that way for Sketch the expression

<<Cube>>.Placement
Setting the whole Placement in one expression

Notes

Notas

  • Ejes y ángulo también pueden expresarse como un quaternion.
  • El punto de referencia de un objeto (FreeCAD.Placement.Base) puede ser distinto, según el objeto de que se trate. Ejemplos para algunos objetos usuales:
Object Reference Point
Part.Box left (minx), front (miny), bottom (minz) vertex
Part.Sphere center of the sphere (ie centre of bounding box)
Part.Cylinder center of the bottom face
Part.Cone center of bottom face (or apex if bottom radius is 0)
Part.Torus center of the torus
Objetos formados a partir de Sketches el objeto hereda la Position del Sketch subyacente. Los Sketches siempre se forman desde la Position = (0,0,0).

Versiones

  • A partir de la version 0.13, la modificación de las propiedades de Placement desde la pestaña Data ha sido desactivada para objetos creados con el entorno PartDesign, salvo para el sketch inicial a partir del cual se creó el sólido. En consecuencia, el Placement de un sólido creado en PartDesign a partir de un sketch solo puede ser modificado ajustando los parámetros Placement del sketch inicial de construcción (el primer sketch, desde el que se creó el sólido).
  • La funcionalidad Placement será manejada eventualmente en el entorno Assembly workbench.

Mas

  • El tutorial: Aeroplane trata ampliamente los mecanismos de modificación del Placement de un objeto.
  • Puede encontrarse una explicación detallada, paso a paso, del diálogo Placement aquí: Tasks_Placement.

Issues

  • Relative Placement of objects will eventually be handled in the Assembly workbench.

More

  • This tutorial: Aeroplane covers the mechanics of changing an object's Placement extensively.