Home Technical Talk

(MEL) Trouble with UI not recreating in the right location

polycounter lvl 16
Offline / Send Message
onionhead_o polycounter lvl 16
global proc pressedBtn(string $btnName){<br>    string $label = `button -q -l $btnName`;<br>    vector $buttonCLR = `button -q -bgc $btnName`;<br>    global int $SetUDIMval;<br>    //global int UDIMsel[] = $SetUDIMval;<br>    global string $UDIMcmd;<br>    if ($buttonCLR != <<0,1,0>>){<br>        button -edit -bgc 0 1 0 $btnName;<br>        $SetUDIMval = (int)(stringRemovePrefix($label,"udimBtn"));<br>        print ($SetUDIMval + "\n");<br>    }<br>    else{<br>         button -edit -bgc 0.365 0.365 0.365 $btnName;<br>         $SetUDIMval = 0;<br>         print ($SetUDIMval + "\n");<br>    }<br>    }<br>//global proc collectUDIMbtn(){<br>    <br>//}<br><br>global proc createUDIMbutton(string $parent){<br>        global string $gridUI;<br>        global string $frame;<br>        <br>     for( $a=1; $a<11; ++$a ){<br>         string $btnName = ("udimBtn" + (1090 + $a));<br>         button -label ((string)(1090 + $a)) -parent $parent $btnName;<br>         button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>            <br>     for( $b=1; $b<11; ++$b ){<br>         string $btnName = ("udimBtn" + (1080 + $b));       <br>         button -label ((string)(1080 + $b)) -parent $parent $btnName;      <br>         button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;     <br>        }       <br>            <br>     for( $c=1; $c<11; ++$c ){<br>         string $btnName = ("udimBtn" + (1070 + $c));<br>         button -label ((string)(1070 + $c)) -parent $parent $btnName;<br>         button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>            <br>     for( $d=1; $d<11; ++$d ){<br>        string $btnName = ("udimBtn" + (1060 + $d));<br>         button -label ((string)(1060 + $d)) -parent $parent $btnName;<br>         button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>            <br>     for( $e=1; $e<11; ++$e ){<br>        string $btnName = ("udimBtn" + (1050 + $e));        <br>        button -label ((string)(1050 + $e)) -parent $parent $btnName;        <br>        button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;        <br>        }<br>            <br>     for( $f=1; $f<11; ++$f ){<br>        string $btnName = ("udimBtn" + (1040 + $f));<br>        button -label ((string)(1040 + $f)) -parent $parent $btnName;<br>        button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>            <br>     for( $g=1; $g<11; ++$g ){<br>        string $btnName = ("udimBtn" + (1030 + $g));<br>        button -label ((string)(1030 + $g)) -parent $parent $btnName;<br>        button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>            <br>     for( $h=1; $h<11; ++$h ){<br>        string $btnName = ("udimBtn" + (1020 + $h));<br>        button -label ((string)(1020 + $h)) -parent $parent $btnName;<br>        button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>            <br>     for( $i=1; $i<11; ++$i ){<br>        string $btnName = ("udimBtn" + (1010 + $i));<br>        button -label ((string)(1010 + $i)) -parent $parent $btnName;<br>        button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>    <br>     for( $j=1; $j<11; ++$j ){<br>        string $btnName = ("udimBtn" + (1000 + $j));<br>        button  -label ((string)(1000 + $j)) -parent $parent $btnName;<br>        button -edit -command ("pressedBtn" + "(\"" +$btnName + "\")") $btnName;<br>        }<br>}<br><br>global proc UDIMLayoutHelper() {<br>    if (`window -ex UDIMLayoutHelper`) {<br>        deleteUI UDIMLayoutHelper;<br>    }<br>        global string $gridUI;<br>        global string $frame;<br><br>        window -title "UDIM Layout Helper" -widthHeight 404 256 -rtf true UDIMLayoutHelper;<br>        $frame = `frameLayout -label "UDIM Grid" -collapsable true -collapse false UDIMGridframe`;<br>        $gridUI = `gridLayout -numberOfColumns 10 -cellWidthHeight 40 40 UDIMbtnGrid`;<br>        setParent -top;<br>        columnLayout -adjustableColumn true -width 150;<br>          frameLayout -label "Setup" -collapsable true -collapse false;<br>          rowLayout -numberOfColumns 2;<br>          button -label "Open UV editor" -width 90 -command "TextureViewWindow";<br>          button -label "Setup UV grid" -width 90 -command "Gridsetup";<br>          setParent ..;<br>          frameLayout -label "UDIM Grid" -collapsable true -collapse false UDIMGridframe;<br>          createUDIMbutton($gridUI);<br>             // setParent ..;<br>                separator -style "in";<br>                rowLayout -numberOfColumns 2;<br>                button -label "Reset Buttons" -command "remakeUI"  resetBtn;<br>            <br><br>showWindow;<br>}<br><br>global proc remakeUI(){<br>    global string $gridUI;<br>    global string $frame;<br>        deleteUI $gridUI;<br>        gridLayout -numberOfColumns 10 -cellWidthHeight 40 40 -parent UDIMGridframe UDIMbtnGrid;<br>        createUDIMbutton($gridUI);<br>}<br><br>UDIMLayoutHelper;<br><br>

So I have script where I create a set of buttons layout in a Grid Format. The Buttons are created in a for-loop to save time and effort, they are being parented to Gridlayout. remakeUI proc is suppose to recreate just  the buttons. So kinda like reset buttons. Unfortunately, right now its not working as intended. If you run the code, 2 UDIM Grids frames gets created for some reason. So im hoping someone can help me with this
Sign In or Register to comment.