View Full Version : UV Vertex Snapper tool help...

11 November 2011, 02:46 AM
Hey all.

I'm learning to create mel and python scripts and would like some help. I want a script that will snap all the points of one object to the corresponding verts of another object based on UVs that share the same UV space between the two objects.

If I wanted to create a script that looked at the position of the UVs of one model and the position of the UVs of another model and if they were in the same space then snap the corresponding vertices from one to the other.. how would I go about doing that?

Would really appreciate any advice.

11 November 2011, 11:18 AM
this sounds straight forward, but could actually be rather complicated. A single vertex may have any number of UVs from 0 upwards.. the single vertex in the center of a 32 sided cylinder cap may have 32 uvs... The first step in writing any script is to actually figure out on paper HOW it is supposed to work, factoring in all of the caveats you can think of. once you have a fool-proof method, then you can start to think about how to code it.

anyway, you can query the uvs from a given vertex using the polyEditUV command. If you are using python rather than MEL you could probably create a dictionary for each object, with one entry (key) for each vertex, the uvs for that vertex being the data. you could then compare each vertex (key) in both dictionaries, the keys that match, you move (snap) that vertex on object A to that position on object B (use the pointPosition command to get vertex positions).

in fact, you wouldn't even need to use a dict, you could just iterate over every vertex in objectA, getting it's uv positions (polyEditUV) and compare the uv list with every iterated vertex uv list in objectB...

at least, If I'm understanding you right...

CGTalk Moderation
11 November 2011, 11:18 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.