PDA

View Full Version : Help with UVW Overlapping faces script...


Fabiomussarela
10-23-2006, 09:15 PM
Hi everyone, Iīm trying to do an UVW overlap check script.

This script will check if an object have faces over faces in the uvw unwrap modifier.

Iīm trying in a scene with 3 objs, a ground box and 2 teapots, one teapot have a decent uvw map with no overlapping, and the other 2 objs have the default max mapping that has overlapping faces.

My code works very well if I run it in just one object selected. but when I create a loop to try over selections it returns that all objetcs have no overlap :sad:.



Global xOverlapObjArray = #()



fn xOverlapObj xObj=

(

addModifier xObj (Unwrap_UVW())

xObj.Unwrap_Uvw.selectOverlappedFaces()

xOverlapFacesArray = #()

xOverlapFacesArray = (xObj.Unwrap_Uvw.getSelectedFaces() as array)



If xOverlapFacesArray.count > 1 then append xOverlapObjArray xObj else print (xObj.name as string + " has no Overlap")



DeleteModifier xObj 1

)






The script should put the objs that have overlap faces in the "xOverlapObjArray" and the ones that havenīt it will just print out the obj names.
If I use this function with just one obj selected, it works fine.

But.....

when I try this:


for o in selection do
(
xOverlapObj o
)


it returns that all objects in the selection have no overlap.


am I doing something wrong?? I hope someone could help me out :)

Thanks a lot in advance.

HalfVector
10-24-2006, 07:47 AM
The problem is that the object being inspected has to be selected (alone). Try this:

xOverlapObjArray = #()

fn xOverlapObj xObj=
(
addModifier xObj (Unwrap_UVW())
xObj.Unwrap_Uvw.selectOverlappedFaces()
overlapCount = (xObj.Unwrap_Uvw.getSelectedFaces()).numberSet
deleteModifier xObj 1
return overlapCount > 1
)

with undo off (
selectionCopy = selection as Array
for o in selectionCopy do
(
select o

if xOverlapObj o do append xOverlapObjArray o
)
select selectionCopy
)

Another good thing to do would be use the suspendEditing/resumeEditing functions so the command panel doesn't flicker that way each time you add the modifier to the selected object. The problem is that if you use the mentioned methods, the selectOverlappedFaces() function won't work anymore. Anyone has a workaround for this?

Hope that helps.

Fabiomussarela
10-24-2006, 01:49 PM
Hi HalfVector, thanks a lot for replying :)



You are right, the problem was that the object being inspected wasnīt selected, but I thought that "for loops" did that automaticaly.

I donīt know why this weird behavior happend, if I use the: "for o in selection" the results are wrong
But, collecting the objects to an "array" like you did , and performing the for loop in the array, I got everything running OK.

I think I donīt know everything I should about "for loops" and "selections" in max.


Another strange thing is that this function only works if the "comand panel" is set to the "modify" mode, if is it at "create" mode or another one, the function returns different results !!!

Well, basically, I have no idea whats going on hehehe :)
I hope someone give us some light :)
Sorry about my english! and thanks a lot again :)

HalfVector
10-24-2006, 05:17 PM
Another strange thing is that this function only works if the "comand panel" is set to the "modify" mode, if is it at "create" mode or another one, the function returns different results !!!
That's right. You have to enter modify mode before. So:

with undo off (
-- You could use also:
-- max modify mode
setCommandPanelTaskMode #modify

selectionCopy = selection as Array
for o in selectionCopy do
(
select o

if xOverlapObj o do append xOverlapObjArray o
)
select selectionCopy
)

Fabiomussarela
10-26-2006, 03:16 PM
Yeah, I figured out :) thanks a lot for your time on this HalfVector.

Now, the only issue is the suspendEditing/resumeEditing problem!!!

the modify panel gets updated on every object, and this really slows everything out!

I hope Bobo could help us on that :)

CGTalk Moderation
10-26-2006, 03:16 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.