RSS FEED

3ds Max SDK: First Steps for Scripters

Even experienced scripters may feel intimidated by the prospect of dipping their toes into the C++/SDK territory, especially when faced with the sheer volume of the documentation and all the topics covered. However, you don't have to go full C++ right away. In this walkthrough, I'll guide you through using the Function Publishing system to develop your own MAXScript functions. I will also demonstrate how to effectively incorporate these functions into a pair of sample scripted simpleMeshMods to get the best of both worlds.

Some topics and features I will only touch on briefly to keep the breakdown concise and actionable. It's not necessary to grasp every little detail on the first read; rather, I would encourage you to come back to revisit parts of the walkthrough and use them as stepping stones to learn more over time.

1. Visual Studio
2. Max SDK
3. Max Plugin Wizard
4. Project Setup
5. First Build
6. Core Interface
7. Core Interface Instance
8. Interface Methods
9. Static Interface
10. Interface Methods Continued
11. THE Core Interface
12. Convenience Features

Read more »

Removing Controller with MAXScript

Since there's no built-in MAXScript function to remove controller once you add it to a parameter, here's a function to do that for you. Big thanks to Larry Minton for revealing how to handle ParamBlock2 PB2Values.

fn removeController subAnim = if isKindOf subAnim ::SubAnim and isController subAnim.controller do
(
    local originalValue = subAnim.value
    local REFMSG_CONTROLREF_CHANGE = 0xFA

    if isKindOf subAnim.parent ParamBlock2 then
    (
        local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
        local pBlockNET = iGlobal.Animatable.GetAnimByHandle (getHandleByAnim subAnim.parent)
        local pValNET = pBlockNET.GetPB2Value (pBlockNET.IndexToId (subAnim.index - 1)) 0

        pValNET.Flags = bit.or pValNET.Flags 0x40 -- set the flag on the PB2Value which controls if the parameter is animated - this effectively removes the controller
    )
    else
    (
        local ctrl = subAnim.controller
        local parent = subAnim.parent
        local index = for i = 1 to refs.getNumRefs parent where refs.getReference parent i == ctrl do exit with i

        refs.replaceReference parent index undefined
    )

    if classOf subAnim.value == classOf originalValue do subAnim.value = originalValue
    notifyDependents subAnim.parent msg:REFMSG_CONTROLREF_CHANGE
)
Read more »
Return to top