Download Version 1.0: jj_worldalign.py

Introduction

JJ_worldalign.py is a basic looking utility that combines the functionality of set position/set value and align to point scripts. On the surface it looks pretty pointless but it does something unique - it will align and/or set the position of points according to world coordinates. If you use modo 201's new 'Item' mode to transform mesh layers or if you parent one of your mesh layers to an item-transformed layer, the whole mesh has an additional transform applied to it. If you try and align point A to the x position of point B that's sitting on another transformed layer, you won't get a successful alignment. Similarly if you use set position to set the y value of Point A to 1m (and your intention is 1m in world) then your result will depend entirely on the local coordinate space of your mesh item.

  • JJ_worldalign.py compensates for any translation, scale and rotation in your mesh layer and aligns points to the world x, y and z of your target point.
  • It works across multiple layers and resolves each layer's vertices to their world position and then aligns to target
  • It 'unravels' the whole parenting hierarchy taking into account all the parent layers above the layer you're working on and collates a cumulative transformation.
  • It can be used as a replacement to set position in that if you use on points across multiple layers that each have different parenting, translation, transformation etc. it will always set points to a single world x, y or z
  • You can align to x, y, or z or any combination of the above.
  • Will work as a conventional align points/set position script on mesh layers that have no item transform.

Usage
The script uses simple arguments:

@jj_worldalign.py align x - aligns to the last selected point's world x
@jj_worldalign.py align y - aligns to the last selected point's world y
@jj_worldalign.py align z - aligns to the last selected point's world z
@jj_worldalign.py align z y - aligns to the last selected point's world z and y (any combo you like)

@jj_worldalign.py setpos x - sets point positions to a world x of your choosing
@jj_worldalign.py setpos y - sets point positions to a world y of your choosing
@jj_worldalign.py setpos z - sets point positions to a world z of your choosing

 

Align to X Normal Style
Here the cube in the centre is a unit 1m cube on a layer with no item scale, rotation or translation. The cube on the left is on a different layer with a simple translation of -1.84m added to it's item translation channel (i.e. moved using the item tool).

If I try and align the points on the cube on the left to the x position of the single vertex on the cube in the middle, you can see what happens.



Align to X with JJ_worldalign.py
Using jj_worldalign.py the points now line up with the x position of the point you've selected. The script ignores the 'local' coordinate space of each mesh layer and works in 'world'

Compensates for any item translation, rotation or scale
Here the leftmost cube is on another layer with translation, rotation and non-uniform scale applied to the mesh layer.

jj_worldalign compensates for all those offsets and accurately aligns the selected points to the x of the last selected point.


Modo's native set position may or may not be what you want..
Here the leftmost cube has been pushed down Y using the item tool. If you use modo's native set position tool and set it to a Y of 1m then this is the result you get i.e. the points are shifted to the local Y 1m of each mesh layer.


Set Position in world space..
Using jj_worldalign you can compensate for the offset on y and have all points line up with world Y 1m.


Versions

Version 1.0:
jj_worldalign.py
- Original version 13.06.2006


Julian Johnson
julian@exch.demon.co.uk