PDA

View Full Version : Get Uv Location


tomkun
05-21-2008, 08:36 AM
hey guys,
I'm trying to find a way to get the Uvs location in the texture editor.
the script I'm tring to do is that when I'll snap one vertex to a point all the others in the shell will move with it relatively, all I need is to know its original Uv location.

oh, one more thing that I didnt think about, which is the most important part of the script.
How can I record in real-time the user actions?

Thanks,
Tomer.

_stev_
05-21-2008, 04:14 PM
To query a UV's location:

polyEditUV -q "pSphere1.map[0]"

I'm not sure about recording the user's actions though.

Stev

swardson
05-21-2008, 08:33 PM
to "record user actions" I am assuming you mean, watch the maya session and trigger events when the user does something. So that once the vertex is snapped, the UV is snapped as well.

For this you will want to look into a scriptJob. It is a bit of code that runs in the background listening for certain events... once triggered it runs the set command you want.

Brad

tomkun
05-22-2008, 10:52 AM
thanks all.
I'll try it.

tomkun
05-22-2008, 02:01 PM
ok, everything is pretty much working but one thing.
the scriptJob doesn't recognize changes at the .map[] attributes.

scriptJob -attributeChange pCube1.map[4] printing;

proc printing()
{
print "hi\n";
}

when I move the uv its doesn't call the printing procedure.
I checked and pCube1.map[4] does change its value.

can you help me on this?

Thanks,
Tomer.

DOor
05-28-2008, 05:24 PM
well with some basic testing I found a flag that ignores the index value of the attribute.
my problem has been I cant catch both the start position AND the end position of the UV in question.


scriptJob -dri -attributeChange pCube1.map[0] snapThis;

global proc snapThis() {
string $sel[] = `ls -sl -fl`;
//print ($sel);

//float $startLoc[] = `polyEditUV -q $sel[0]`;
//print $startLoc;

float $endLoc[] = `polyEditUV -q $sel[0]`;
print ($endLoc);
}


I may need to catch a change in the selected UVs which would then initiate a new scriptJob and record the start position before hand. then use a while loop to catch a value returned by the script job.

im not sure yet. ill be doing some further testing as this has been a problem I wanted to fix for a while-- crappy snapping in the uv text editor. but the -dri flag seems to fix the problem you were having.

hope this helps.

mhovland
05-28-2008, 10:10 PM
I am wondering why you want to capture the users actions at all.

I wouldn't use a script job at all, I would:


get the position of the selected UV before the move.
convert the selection to the shell, and store all the UV's names in question.
after the UV move is completed, loop through all the names and move them the same amount in u and v.


This is my first thought off the top of my head, and I don't have time to test it right now, but should work fine.

CGTalk Moderation
05-28-2008, 10:10 PM
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.