Hi there,
At the company I work, we use a large library where when we import/merge a certain object, it is being imported at the 0.0.0 cordinate. I would like to have a command (shortcut too) in order to move the selection to the center of my screen. We would benefit very much if we could have this possibility.
Looking forward to some comments,
Thanks in advance.
Best,
Remy
Solved! Go to Solution.
Solved by har1sf0x. Go to Solution.
Solved by Swordslayer. Go to Solution.
You can get the intersection of viewport center ray and the XY plane and move the object there:
fn getXYViewIntersection = ( local intersection = [0,0,0] local viewTM = inverse (viewport.getTM()) manip.msXYPlane.intersect (ray viewTM.pos viewTM.row3) &intersection return intersection ) $.pos = getXYViewIntersection()
Thank you for your reply and the code.
Maybe i am understanding it wrong or i did not made my intentions clear enough.
The idea of the script should actually be; that my current selection needs to be moved toward the center position of my screen (which won't be point 0.0.0), this could be any place in the XY world ofcourse. That i why i like the selection to be moved toward the center point of my screen.
What happens now is when i Evalluate the script, the my current selection will move to the point 0.0.0.
Hopefully I made it a bit more clear now.
Thank you 🙂
Maybe I misunderstood what you mean by center of the screen. The code will move the selection to the center of the active viewport, in all viewports default state, that is [0,0,0], if you pan the viewport, it's a different position. If you use a viewport where no intersection with XY plane is possible, replace XY in the code with a different plane.
Can you make a before->after picture? Still have trouble imagining what exactly is it that you want.
Hello,
my wild guess is that he wants to pan the view and while the script evaluates the selected object should move only in the (x,y) plane of the orthographic view without changing the z value.
@har1sf0x wrote:
Hello,
my wild guess is that he wants to pan the view and while the script evaluates the selected object should move only in the (x,y) plane of the orthographic view without changing the z value.
I'll just wait if he replies since this doesn't make sense to me in the previous context (problem being that imported objects are placed at the origin vs center of the screen).
haha, oke. I'm probably not clarifying myself enough. I'll attach two screenshots to explain it better.
So in the first picture, you see a top view. I've imported a model from our stock; it gets merged into the scene the at 0.0.0. and it stays selected.
In the second picture, I'm still in the top view but i have just panned a bit towards a side so that point 0.0.0 and the imported model are not visible anymore.
What i want the script to do is that when I evaluate the it; is that the selection will move towards the center of my second screen. The model only has to move on the X and Y axis. Not the Z axis because it doesn't need to move in the height.
I hope this clarifies things.
Thanks.
@Anonymous: umm... but... that's exactly what the script I originally posted does...
Edit: my mistake, it does that in every non-ortho viewport, so perspective is fine, top view is not. The reason is that in those cases, viewport position lies on the plane so intersection fails... oh well... to make it work, edit it this way:
fn getXYViewIntersection = ( local intersection = [0,0,0] local viewTM = inverse (viewport.getTM()) manip.msXYPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection return intersection ) $.pos = getXYViewIntersection()
Thank you!
Indeed this what I tried to achieve! Thank you very much.
Take care.
Remy
Hello again.
I added @Swordslayer code the ability to evaluate in each view, orthographic or even perspective in the same manner.
fn getXYViewIntersection = ( local intersection = [0,0,0] local viewTM = inverse (viewport.getTM()) case (viewport.getType()) of ( #view_left: (manip.msYZPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) #view_right: (manip.msYZPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) #view_top: (manip.msXYPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) #view_bottom: (manip.msXYPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) #view_front: (manip.msXZPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) #view_back: (manip.msXZPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) default: (manip.msXYPlane.intersect (ray (viewTM.pos + 10 * viewTM.row3) viewTM.row3) &intersection) ) return intersection ) $.pos = getXYViewIntersection()
Enjoy
Can't find what you're looking for? Ask the community or share your knowledge.