View Full Version : Need to find the UV coordinates of a Editable Poly Vertex

07 July 2006, 08:35 PM
I need to write a function that takes as arguments an editable poly object and the index of a vertex, and then returns the position of the vert's corresponding UV coordinate in a Point3 value.

This is all I have so far:

fn getUVpos epolyobj vertindex =

return uvpos = [-1,-1,0] -- insert wisdom here

Does anyone have any ideas how to do this? Any thoughts would be greatly appreciated. Thank you.

07 July 2006, 10:42 PM
I found something that works, but I had to use editable mesh. But I won't argue with results.

fn getUVpos epolyobj vertindex =

local obj = copy editpolyobj
converttomesh obj
UVcoords = getTVert obj vertindex
delete obj
if true then return UVcoords


One more thing: Anyone know what the & symbol represents in Maxscript?

07 July 2006, 11:21 PM

It is used for referencing variables:

fn getVal obj &vert &edge &face = vert = ...; edge = ...; face = ...

So later you can call this fn like this:

getVal &v &e &f
format "%\n" #(v, e, f)


07 July 2006, 11:59 PM
Keep in mind that one vertex could has more than one texture coordinate.

Said that. Say you want to take the texture coordinates for the four vertices that form the face #3 (map channel #1) of a box (previously converted to an editable poly object). What you'll do is something like this:

for v in (polyOp.getMapFace $Box01 1 3) do
format "Vert #% UVW = %\n" v (polyOp.getMapVert $Box01 1 v)

That will print the texture coordinates for that face.

Take a look to the Editable_Poly mapping methods in the MAXScript reference for more info.


07 July 2006, 09:03 AM
Here is the code:

fn getUVpos obj channel theVertex = (
local vertexFaces = polyOp.getFacesUsingVert obj #{theVertex}
local mapVertsArray = #() , mapVertsPosArray = #() , optimizedMapVertsArray = #() , optimizedMapVertsPosArray = #()
for currentFace in vertexFaces do (
local polyFace = polyOp.getFaceVerts obj currentFace
local mapFace = polyOp.getMapFace obj channel currentFace
local mapVertex = mapFace[findItem polyFace theVertex]
append mapVertsArray mapVertex
local mapVertexPos = polyOp.getMapVert obj channel mapVertex
append mapVertsPosArray mapVertexPos
if findItem optimizedMapVertsArray mapVertex == 0 do (
append optimizedMapVertsArray mapVertex
append optimizedMapVertsPosArray mapVertexPos
format "mapVertsArray=% \n" mapVertsArray
format "mapVertsPosArray=% \n" mapVertsPosArray
format "optimizedMapVertsArray=% \n" optimizedMapVertsArray
format "optimizedMapVertsPosArray=% \n" optimizedMapVertsPosArray

if selection.count!=0 and classof selection[1]==Editable_Poly
do (
local obj=selection[1]
local channel=1
local theVertex=5
getUVpos obj channel theVertex

It returns an array.
In many cases this array will contain only one point3 value.
In fact the function calculates an optimized array but I left the unoptimized array in the code if you need some.

I Hope this helps

CGTalk Moderation
07 July 2006, 09:03 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.