Notifications
Clear all
[Closed] viewportTM, and the matrix
Dec 10, 2009 4:21 pm
Hi,
OK, so at the risk of showing how much I don’t understand about the matrix I’m going to post my problem.
This script aligns the current selection to the minimum object in the x axis, but it doesn’t work when the viewport TM is in two out of four quadrants, for example:
In the current iso orthographic view, if the current viewportTM is looking towards the x, y or -x, -y then it doesn’t align properly. In the other two cases, -x,y and x, -y hey presto.
Can you help?
(
sel=selection as array -- get the selections as an array.
tm=(inverse (viewport.getTM())) -- get the current screen coordinate matrix.
selpos=#() -- set an array to hold the positions of the objects in the selection set.
in coordsys tm selpos=for s in sel collect s.pos.x -- collect all of the object positions in the screen coordinate system.
t=tm.row1
m=0
m=t[1]+t[2]+t[3] -- let's work out if it the normal or reverse view by adding each axis of the TM row1 (answer will be positive or negative),
if m<0 then -- collect the min or max value depending on the view (normal or reverse)
(
in coordsys tm seladj=for s in sel collect s.max.x
) else
(
in coordsys tm seladj=for s in sel collect s.min.x
)
v=amin seladj -- get the lowest position in the selection set
newpos=for x=1 to sel.count collect (v+selpos[x]-seladj[x]) -- set the target values to the lowest position, and adjust for object width
for j=1 to sel.count do -- set the new positions
(
in coordsys tm sel[j].pos.x=newpos[j]
)
)
Josh.
1 Reply
Dec 10, 2009 4:21 pm
Hi guys,
I know someone can help with this so I’m going to give it a little bump. Please say if you need a better description of what I’m doing.
Josh.