[Closed] UVW Packer by Element Tool
Hello, I am looking for a solution on a problem I can’t seem to get right.
I have a selection of 3 objects. Each have a UVW_Modifier on them already, so I don’t need to worry about that.
What I want to do is press the “Pack Together” tool after I have selected the Element of each object one by one on a loop that ends when i get to the end of my selection of objects.
The reason for this is so that I have a nicely stacked pile of uvs on top of eachother, rather than them all compact into the square seperated (helpful for procedural uving), and they do not scale.
Here is my code, can someone assist in what I am doing wrong?
(
(
(
global EUUTool = “Element UV Packer”
theObjs = selection as array
max modify modefor obj in theObjs do ( select obj unwrapMod=Unwrap_UVW() modPanel.setCurrentObject unwrapMod selection[1].modifiers[1].pack 1 0.02 true false false ) )
)
)
When you create a modifier Unwrap_UVW() it is not automatically applied to any object. So before you can use modPanel.setCurrentObject do addModifier obj unwrapMod.
Also, instead of using selection[1].modifer[1].pack you can do unwrapMod.pack.
Here’s a snippet that can help you out.
(
obj = $
uv = obj.unwrap_uvw
allFaces = #{1..(uv.numberPolygonsByNode obj)}
while not allFaces.isEmpty do
(
uv.selectFacesByNode #{allFaces.numberSet} obj
uv.selectElement()
uv.pack 1 0.0 true false false
allFaces -= uv.getSelectedPolygonsByNode obj
)
uv.selectFacesByNode #{} obj
)
Hey thank you for this! It does open a new way to write what I am trying to do. Hopefully with this new way I will be able to fix my “Selecting all objects in the scene problem”.
Do you know how I could fix the other problem I am having which is when I click the button, my uvs are already unwrapped. They are the correct scale and everything, I am literally just trying to stack the ones that are common on top of each other.
So in short: Do you know how to turn off the scaling feature of pack? Like Pack together, not Pack Custom with Rescale checked on.
I feel dumb. Normalize is apparently another word for scale, even though I have tried this several times. so just siwtch “uv.pack 1 0.0 true false false” to “uv.pack 1 0.0 false false false”.
The last thing I am trying to figure out now, though is it seems to be doing every object in the scene. Not just my selection. I am assuming this is because its something with the way I am writing it and my code logic.
This is already working. I swear I stepped into a parallel universe. Nevermind, thanks guys. There is the full script for anyone to use.
Hey Icy,
Why don’t you just right click and copy, the select all the common ones and paste.
Hmm. I will talk to the artist I am working with about it. Basically we are working on a scene with thousands of small objects.
The biggest issue is how do we get it down to as few button clicks as possible, but tbh I didnt think of that. I will bring this up. Btw thank you so much for showing interest in this! You are awesome man, so I will go into depth and share the knowledge I gained from this.
Select Element () does not work the same in UVS as it does in Geometry. Geometry selects all planes. It does not however work like that in UVS. It selects the UV islands when you do UV island not to be confused by the toggle button, but the way it works in UV editor when you open it. So scripting has to be kind of worked around like that. So unfortunately we couldn’t get it down to one button click, but rather a few. 2-3.
All of this was in an effort to make it usable for procedural generated maps. We have to hand unwrap models, but we wanted a pack together to act in a way that was like pack together, but it stacked the common ones, because UV Space ain’t cheap. But yeah, that is the gyst if that makes sense?
Thanks again.