|UI location||View3D > Tool Self > Precise Align|
|Version||1.2||Author(s)||Bit Barrel Media|
|Current version download||https://developer.blender.org/T31620|
|Python modules||math, mathutils|
It is very difficult and in some cases simply impossible to precisely align objects within Blender. This is ok for organic modeling but unacceptable for mechanical modeling. This script solves that problem.
With this script you can select three vertices and it will create an empty aligned with the normal and an edge of that face. This empty can be parented to the object and this way any face on the object can be precisely aligned with any face on another object.
Additionally, you can change the local transform orientation of an object in rotation as well, instead of just the build-in "set origin" feature. Combined with the feature above, you can precisely align the local transform of an object with a custom face created by three vertices and an edge of that face.
- Put the script in /Blender/x.xx/scripts/addons
- Activate script (press checkbox) in File > User Preferences > Addons > 3Dview > Precise Align
- A "Precise Align" panel will appear in 3D View > Tool Shelf > Relations tab (on left side of screen, press T to toggle Tool Shelf).
- Create an Empty and align it with a face specified by three vertices and an Edge on that face.
- Change the Normal, Edge, and Tangent vector direction on the fly.
- Map the Normal, Edge, and Tangent to any X,Y,Z axis.
- Swap the location of the Empty to each vertex.
- Option to automatically parent the Empty to the active Object.
- Change size of connected empty on the fly.
- Automatically sets the Empty to X-Ray and Arrows display mode.
- Select any empty in the scene and set it as the source for the Local Transform.
- Set the Local Transform Rotation of an Object to the rotation of an empty.
- Set the Local Transform Position of an Object to the position of an empty.
- Align the rotation of an Object with the rotation of an Empty.
- Align the position of an Object with the position of an Empty.
- Select the Object you want to align and go to Edit mode.
- Press "a" to deselect all.
- Select three vertices.
- Select "Create Empty". An Empty will appear at one of the Edge vertices and it will be aligned with the face normal and edge vector. Note the name of the Empty in the "Source Transform:" field. The name is based on the Object name which is active. If you make another Object active in Edit mode which has a Source Transform added to it as well, the script will automatically select the correct empty based on the Object name. Because of this, do not manually add an Empty to the scene with the same naming convention.
- Use the "Flip Vector", "Map Vector", and "Swap Empty Origin" items to further refine the orientation of the empty.
- If you change your mind and want to use other vertices after an Empty already has been created, just select the other vertices and then select one of the Flip Vector items to update the Empty position.
- Make sure that the vector flipping and mapping makes sense so the objects will be correctly aligned.
- The program will only work if you create an empty with a right handed coordinate system. If a left handed coordinate system is created, an error will be shown.
Workflow continued: Aligning Objects
- Let's say we want to align the face, edge, and vertex of the two objects shown here:
- Set "Parent to Object" to make the Empty the parent of the Object.
- Go back to Object Mode then select another object.
- Repeat the steps above for the other object.
- Go to Object mode and select "a" twice to deselect all.
- The scene should now look something like this:
- If you want to align Object A to Object B, select the Empty from Object A first, hold shift, then select the Empty from Object B.
- Select "Align Object->Position". The selected Object will be positioned to the active Object with the empty as a reference.
- Select "Align Object->Rotation". The selected Object will be rotated to the active Object with the empty as a reference.
- The scene should now look something like this:
Workflow continued: Setting Local Transform Orientation and Position
- Let's say the Local Transform Orientation is rotated incorrectly as shown here:
- Place an Empty with the correct orientation using the first workflow steps. The scene should now look something like this:
- Go to Object mode and select "a" to deselect all.
- To set the local transform of an Object to the transform of an Empty, select the Object first, hold shift, then select the Empty. Alternatively, you can select only one object, and it will be automatically aligned to it's Source Transform.
- Select "Align Local Transform->Position" or "Align Local Transform->Rotation". Note that all parent information of the Object will be lost when doing this (Object will be placed in the root of the tree). All children of the Object will be left alone though.
- If you want the Local Transform Position to be located at the center of the object, you need to place the 3d cursor there first. This can be done by going to Edit mode, Press the Vertex Select button on the bottom of the 3d view. Select "a" twice to select all, or shift-click to select other vertices. Then press shift-s > Cursor to Selected. Then select "Origin to 3D Cursor". Alternatively, you can place the Empty at the center of the object with shift-s -> Selection to Cursor. Then press "Align Local Transform->Position".
- The scene should now look something like this:
- Normal: Flips the face normal vector.
- Edge: Flips the Edge vector.
- Tangent: Flips the vector which is a tangent from the Normal and Edge vector (cross product)
Map Vector: (X,Y,Z): Maps the Normal, Edge, and Tangent vector to one of the axis. Be sure you do not have two or more same axis set. Only right handed coordinate systems are valid.
Swap Empty Origin: Swaps the vertex where the Empty is connected.
Parent to Object: Automatically parent to Empty to the Object. Useful for aligning Objects.
Size: The size of the Source Transform Empty which is added to the Object.
-I can't see the "Create Empty" Button.
- Check you have correctly installed the script.
- The "Precise Align" menu is in 3D View > Tool Self > Relations tab (press t to show Tool Shelf).
- You have to be in Edit mode to create an Empty.
-I press "Create Empty", but nothing happens.
- Three vertices must be selected
- Map Vector must not have two or more the same axis types. For example, you can't have X,Z,Z. It must be for example X,Z,Y
- Only a right hand coordinate system is valid. If a left handed coordinate system is created, an Empty will not be created
- I change the Flip Vector or Map vector items but nothing happens.
- The item "Source Transform" must indicate an Empty. If it does not, add an Empty first.
- I select an align button in Object mode but nothing happens.
- Two Objects must be selected. Alternatively, only one Object can be selected, but it's Source Transform Empty must be available.
- The Empty is a right hand coordinate system. Go back to Edit mode and change it.
- When using the Align Object Local Transform feature, The parents of the Object will be cleared (the object will be placed in the root of the tree), but any children will be left alone.
- Note the name of the Empty in the "Source Transform:" field. The name is based on the Object name which is active. If you make another Object active in Edit mode which has a Source Transform Empty added to it as well, the script will automatically select the correct empty based on the Object name. Because of this, do not manually add an Empty to the scene with the same naming convention.
- Swapping the Edge vertex might change the orientation of the Empty.
- In order to update the error message of the Empty when coming from Object mode with an Empty already created, cycle one of the Flip Vector or Map Vector items.
-Added "Set Source Empty" button.
-Parent status of empty is updated if related checkbox is changed.
-Fixed a bug which rotated the entire Object instead of just the local transform when "Align Object Local Transform" is selected with "Source Empty Fixed" set to Yes.
-Fixed a bug which prevented the "Align Object Local Transform" feature from doing anything when "Source Empty Fixed" is set to Yes. and both the Object and the Empty are selected with the Empty being active.
-Added align feature
-Added feature which automatically clears any parented Objects when using the Align Object Local Transform feature. This is done because if the Object has any parents, it will mess up the transformation setting.
-Fixed a bug which caused a script crash when using in anything other then Scripting view.
-Slightly modified the name of some panel items.
-Automatic x-ray on for Empty.
-Fixed a bug with the Align Object logic which made it behave incorrectly.
-Removed "Source Empty Fixed" item. Now, if a Source Empty is shown, it is Fixed as well.
-Fixed a bug which caused a crash of the script.
-Added "Origin to 3D Cursor" button.
-Fixed a bug (similar to the one in v0.7) which caused a crash as well.
-Removed the "Set Source Empty" button. The source empty will now be given a name based on the object to which it is added. This name is used as a reference to keep track of which Empty belongs to which object.
-Can now set the position of the Local Transform or the Object orientation separately.
-Changed layout and changed "Source Empty" to "Source Transform".
-Fixed a bug with Align Object: Position. It did now work correctly when the active object was a child of another object (used local position instead of global).
-Fixed a bug with the Align Local Transform logic which caused incorrect rotations.
-Fixed a bug which caused matrix trashing caused by the user creating a left handed instead of a right handed coordinate system.
-Feedback given if the Empty Coordinate System is invalid.
-Changed selection system from one Face and an Edge to 3 vertices instead. This provides more flexibility for Coordinate System creation.
-The parent is automatically removed when using Align Object Rotation as well, otherwise the rotation doesn't work.
-Removed error saying that context.active_object.name does not exist.
-Fixed compatibility issue with Blender 2.67
-Added error message when left handed coordinate system is detected in object mode.
-Moved the Precise Align panel to the Relations tab for Blender 2.7