Home Technical Talk

3Ds Max - Bind MAXScript to a Key ISSUE

polycounter lvl 9
Offline / Send Message
EliasWick polycounter lvl 9
Greetings amazing creatures! I have run into a little problem of when it comes to biding a script to a Key in 3Ds max, and I would love to get some information on what I might have done wrong. So generally speaking I want to my script to run when I press a key.

So in order for me to get the script to even appear in the Keybindings menu I have to add a few lines such as:
macroScript Test
category:"Test"
toolTip:"Testing"

This allowes me to find my Script in the Keybindings menu, but when I bind it to a key and try to run it, the script doesn't work. It won't start and nothing happens. When I drag and drop the script onto my scene it works. But nothing happens when I press the button that I have bound it to.
TO note: I am using 3Ds Max 2015. The script is saved as an MCR file.

Here below is the script, There will be a link to Paste bin as well for easier reading:

macroScript testing
category:"test"
toolTip:      "testing the test"

(

)

rollout UVTool "UV AutoUnwrap V0.6"
(
    spinner mapChannelNo "Map Channel: " range:[0,100,2] type:#integer
--    spinner customFlattenAngle "Angle: " type:#float range:[0,1000,45.0] scale:5.0
    spinner spacing "Spacing: " type:#float range:[0,100,0.007] scale:0.001
--    checkbox packed "Pack" checked:true
    button unwrap "Unwrap"   


    -- ==============
    -- MAIN SCRIPT
    -- ==============

    on unwrap pressed do
    (
        -- creates an array from suitable geometry in selection
        local geoToUV = (for o in selection where (isKindOf o GeometryClass and canConvertTo o Editable_Mesh) collect o)
       
        -- checks to see if anything will be unwrapped, and generates error popup if not
        if geoToUV.count == 0 then messagebox "No suitable geometry selected!"
        else
        (
            clearSelection()    -- clears selection once original selection has been saved as geoToUV array

            for i in 1 to geoToUV.count do    -- loops through array of suitable geometry
            (
                select geoToUV[i]    -- selects "i"th piece of geometry
                   
                -- main UVW block
                modPanel.addModToSelection (Unwrap_UVW ()) ui:on
                geoToUV[i].modifiers[#Unwrap_UVW].unwrap.setMapChannel mapChannelNo.value
                geoToUV[i].modifiers[#Unwrap_UVW].unwrap.move ()
                geoToUV[i].modifiers[#Unwrap_UVW].texMapList.count = 0
                geoToUV[i].modifiers[#Unwrap_UVW].texMapIDList.count = 0
                geoToUV[i].modifiers[#Unwrap_UVW].baseMaterial_list.count = 1
                geoToUV[i].modifiers[#Unwrap_UVW].baseMaterial_list[1] = undefined
                geoToUV[i].modifiers[#Unwrap_UVW].texMapList.count = 0
                geoToUV[i].modifiers[#Unwrap_UVW].texMapIDList.count = 0
                geoToUV[i].modifiers[#Unwrap_UVW].texMapList.count = 1
                geoToUV[i].modifiers[#Unwrap_UVW].texMapIDList.count = 1
                geoToUV[i].modifiers[#Unwrap_UVW].texMapList[1] = Checker ()
                geoToUV[i].modifiers[#Unwrap_UVW].texMapIDList[1] = -1
                subobjectLevel = 3
                actionMan.executeAction 0 "40021"
                max select all
                geoToUV[i].modifiers[#Unwrap_UVW].flattenMap 45.0 #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) (spacing.value/2) true 0 true true
                subobjectLevel = 0
               
               
                -- packed section - still issues with packing code. Also, no longer works within UI
                --    if packed == true do
                --        (
                --         selection[i].modifiers[#unwrap_uvw].unwrap.move ()
                --         subobjectLevel = 3
                --         max select all
                --         selection[i].modifiers[#unwrap_uvw].pack 1 0.007 true true true
                --         subobjectLevel = 0
                --        modPanel.addModToSelection (TurboSmooth ()) ui:on    -- Tests to see if this block works
                --        )
               
               
                clearSelection()
            )
            select geoToUV#() -- selects geometry which has been modified
        )

    )
)
   
createDialog UVTool width:200

____________________________________________________________________
Thanks for reading and a large thanks to the one who can help me, or at least tries.

Replies

Sign In or Register to comment.