I'm trying to create a script that gets the current UV unwrap of an object and then fits it into the UV 0-1 square WITHOUT REARRANGING IT and only set the distance between the borders of the UV 0-1 square and the pieces inside WITHOUT STRETCHING/SQUASHING THEM. (A Refercence for that could be the way Marvelous Designer fits the UVs).


I was thinking that I could do this using the Pack islands options. However, it doesn't have any options that come with it NOT to rearrange the islands which doesn't work for me, I need them exactly as they are, just in a different scale. Thought about trying to get to the code and work from there but sadly, this part is writtn in C and not exposed to Python.. Any ideas for this one?

I gave up on the first option and thought of another way to do this.. Just use the option "Constrain to image bounds" and scale at a really high value. Sadly, this also doesn't work due to this option not working properly... Sometimes the selection gets out of the UV 0-1 square even with the Constrains turned on. Also, if one of the axis reach the border and stops there, the other one continues scaling until it reaches the border which stretches the islands.. I found that if you stretch the selection from coordinates 0,0 - you don't have problems with selection coming out of the bounds, but in my case the resizing happens from the middle of the UV (coordinates 0.5, 0.5)


I know the scale works in percentages and I also know that there's kind of a trick for making it work in metric units in the 3D viewport by using Push/Pull. I need however to find a way to set a distance in metric units. Do you guys think there's some kind of a trick to do that?

Any ideas of ways to pack islands without rearranging them (so that the "Margin" option can be kept (I think it uses meters as units))? Also, the "Pack Islands" options packs the islands and arranges them to the bottom left corner, which also doesn't work for me, I need to either arrange them to the top left or have the option to choose. Any ideas?

When manually resizing something, after clicking "S" and clicking to "acceopt" the resizing you get the "Resize" panel where you can still change things before the resize operation is ofiicially over. Is there a way to get this window with Python? If not, is there a way to write the "values" of the final resizing when using bpy.ops.transform.resize?

# A little explanation about this:
I found a way to fix the constrains to work for me but my method only works manually.
I constrain the editing, scale manually to the maximum possible and then look at the
Resize panel and put the lower value to both x & y. But if I use
bpy.ops.transform.resize(value=(1000, 1000, 1000)) for example,
I don't get the actual values of scaling up with the constrains so I can't make it do
the scaling without stretching.
  • $\begingroup$ If I understand you right, you'd have to find the max x and y coords per island and calculate the distance to the borders (ideally the bounds as well) and then scale it accordingly using bmesh, which is e.g. explained here: blender.stackexchange.com/questions/111234/…, guess there are lot more batANSWERS to this. $\endgroup$
    – brockmann
    Commented Nov 6, 2021 at 16:07
  • $\begingroup$ Also have a look into TexTools Add-on, the crop function might does what you want. $\endgroup$
    – brockmann
    Commented Nov 6, 2021 at 16:45
  • $\begingroup$ I'll go through these links thoroughly and come back with an answer if any of that helped me reach my goal $\endgroup$
    – Aleks K.
    Commented Nov 6, 2021 at 19:53
  • $\begingroup$ @brockmann I went through these links and sadly, they don't help.. I went through the code of the Add-on and it calculates the distance from the borders in pixels which doesn't work for what I need. Honestly, I'm not sure if what I want to achieve is even possible due to the nature of how things work in Marvelous Designer. The other link can help me scale the UVs but, since there's no way to mesure the UV space in millimeters, that's not needed. If you have any other ideas though, please share them. I was thinking I can do this using the DXF format but need to read more about that to confirm. $\endgroup$
    – Aleks K.
    Commented Nov 15, 2021 at 8:46


You must log in to answer this question.

Browse other questions tagged .