Fetch can tell you the current height, width, left, and top of a token. (Note: requires Fetch v2.0) @(selected.height) @(selected.width) @(selected.top) @(selected.left) It can even tell you the snapping increment of the page the token is on, so you could know the position of the gridlines: @(page.@(selected.pageid).snapping_increment) ZeroFrame can defer an inline roll to do modulo math using the info returned by Fetch, or MathOps could do it without deferring. MathOps version for top: {& math @(selected.top) % (@(page.@(selected.pageid).snapping_increment)*70)} ...and for left: {& math @(selected.left) % (@(page.@(selected.pageid).snapping_increment)*70)} Of course, that is to the center of the token, so if you want to align the upper left corner to the grid, you have to adjust your starting figure to account for half of the height/width. The actual upper left corner is found as: TOP : {&math @(selected.top)-(@(selected.height)/2)}
LEFT: {&math @(selected.left)-(@(selected.width)/2)}
Which would make the modulo operation for the upper left corner: TOP : {& math (@(selected.top)-(@(selected.height)/2)) % (@(page.@(selected.pageid).snapping_increment)*70)} LEFT: {& math ( @(selected.left)-(@(selected.width)/2) ) % (@(page.@(selected.pageid).snapping_increment)*70)} Those numbers would tell you how far the upper left corner was displaced from aligning to the grid... so you could use them right in a TokenMod command line to move the token that far. Those numbers are "right" and "down" measurements of displacement, so to use those numbers for grid alignment, you would need to change the sign so that the token would always be moving the token up and to the left. If you would rather move it down and to the right to get it to align, you'd have to subtract those displacement numbers from the grid size of the page. To explain... imagine the token has a top displacement of 23. That means it is 23 pixels below aligning to the grid, or (putting it another way) the grid line is 23 pixels above the upper left corner. You could therefore move the token 23 pixels up to align it, or your could move it the remainder of the grid square down to align it to the next grid line. The height/width of a grid square is the portion of the equation where you see the snapping increment multiplied by 70 (the default 100% resolution): (@(page.@(selected.pageid).snapping_increment)*70) TL;DR So, working from the upper left corner, the final equation for "how far to move the token down" is: {& math (@(page.@(selected.pageid).snapping_increment)*70)-( (@(selected.top)-(@(selected.height)/2)) % (@(page.@(selected.pageid).snapping_increment)*70))} ...and the final equation for "how far to move the token to the right" is: {& math (@(page.@(selected.pageid).snapping_increment)*70)-( (@(selected.left)-(@(selected.width)/2)) % (@(page.@(selected.pageid).snapping_increment)*70))} REQUIRED SCRIPTS: Fetch, MathOps, TokenMod, and ZeroFrame (if you don't install MathOps after Fetch)