Home Technical Talk

Help needed with maxscripting.

Osane
polycounter lvl 5
Offline / Send Message
Osane polycounter lvl 5
Hi guys!
I got huge difficulties to figure out how to write a script that can make pixel padding between the UV elements based on resolution in Unwrap UVW modifier.
I found one script from internet http://www.scriptspot.com/forums/3ds-max/general-scripting/maxscript-uv-pixel-padding which works perfect for one object selected but if I have multiple objects selected it works funny and does not keep "Normalize - off" in account.

I tried to contact the guy that made this script via email to ask if its a bug or not...I didnt got answer. I also asked almost everywhere and dont get any answer(kinda depressing), so Polycount is my last hope.
How do you guys figure out things like that? I tried to find out the logic the guy is using for the padding but I am getting lost with the variables and I cannot follow it...

Could it be possible for you guys to help me just theoretical how I could write something like that or where to eventually look for solution or examples.

Thanks in advance.

Replies

  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Mmh wouldn't you just have to specify the proper ratio in the unwrap.pack spacing ?
    If you get the resolution of your map, let's say 2048, and want a padding of 8 pixels, set spacing to 8/2048 (0.004)

    Also take a look at
    http://www.polytools3d.com/polyunwrapper/index.html
    It's a nice tool, and it packs by pixel. Not sure how it behaves on multiple selection tho.
  • Osane
    Options
    Offline / Send Message
    Osane polycounter lvl 5
    Mmh wouldn't you just have to specify the proper ratio in the unwrap.pack spacing ?
    If you get the resolution of your map, let's say 2048, and want a padding of 8 pixels, set spacing to 8/2048 (0.004)

    It works but not always, Unwrap UVW pack is behaving very randomly, throwing the uv elements here and there.
    Here is the code I am using, I am not sure if this is the optimal way to write it.
    max modify mode
    selObjsArr03 = selection as array
    for o in selObjsArr03 do
    (
    select o
    UnwrapMod = $.modifiers[1]
    UnwrapMod.pack 0 0.004 false false true
    )
    Thanks for the "Polyunwrapper" suggestion but I would like to find out how I can write it. Kinda for experience too.
  • Osane
    Options
    Offline / Send Message
    Osane polycounter lvl 5
    Anyone? I have the feeling that the array does not work well with the unwrap modifier because if I use the script on one object it works, almost but it works.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    That's because you pack each object apart in your loop.
    You have to share the same unwrap modifier then pack objects together.
    (
    max create mode
    sel = selection as array
    padding = 0.004
    unwrap = Unwrap_UVW () --declare the modifier
    for o in sel do addModifier o unwrap --add it to each object
    max modify mode --force register
    unwrap.pack 0 padding false false true
    )
    
Sign In or Register to comment.