ScriptSpot

Forum topic · General Scripting

Preserve Uvs doesn't work with maxscript

By myland · 2019-06-12

Description

Hello everyone,

I am struggling once again with something that make me crazy.

When moving Vertex with Maxscript the "Preserve UVs" mode doesn't work at all I mean it is activated but doesn't do its job.

Of course that works when I move it manually in the scene instead of using maxscript.
By the way I use it on a flatten mesh (Either a plane or a mesh that I flatten by using UV map datachannel)

here is the code I used to move my vertices:


ClearListener()

$.preserveUvs = true
Origin = $.pivot

Sel = (polyop.getVertselection $) as array

for i in Sel do
(
Vpos = polyop.getVert $ i

dir = transmatrix (Origin - Vpos)

Pos1 = (if dir.position[1] > 0 then -20 else if dir.position[1] < 0 then 20 else if dir.position[1] == 0 then 0)
Pos2 = (if dir.position[2] > 0 then -20 else if dir.position[2] < 0 then 20 else if dir.position[2] == 0 then 0)

in coordsys dir ( polyop.moveVert $ i [Pos1, Pos2, 0]) --move each vertex of my selection further to the pivot point

)