Add Force to the Spring


When I add force to the spring I got the error:

delete objects
Obj = teapot isselected:true
SC = Obj.position.controller = SpringPositionController()
append SC.forcenode (gravity())
-- Runtime error: Array parameter size fixed, cannot append: forceNode

Any trick to fix this? Maybe by using Autodes.max and twerking jiggle class?


yep… it is possible

delete objects

spc = SpringPositionController()

g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
anim = g.animatable.GetAnimByHandle (dotNetObject "system.uintptr" (getHandleByAnim spc))
gr = gravity()
INode = g.coreinterface.getinodebyhandle gr.inode.handle
pb = anim.getparamblock 1
pb.Append (pb.indexToID 0) 1 INode 0
Obj = teapot isselected:true
Obj.position.controller = spc


– Runtime error: .NET runtime exception: Unable to cast object of type ‘Autodesk.Max.Wrappers.INode’ to type ‘Autodesk.Max.Wrappers.ReferenceTarget’.


Oh, indeed… works in 2014 but not in 2020.
You can compile c# dll and try it that way. Sometimes it helps and sometimes not. :expressionless:
I couldn’t make it work on the mxs side.

using System;
using Autodesk.Max;

public class MyClass
    static IGlobal globalInterface = GlobalInterface.Instance;
    static IInterface coreInterface = globalInterface.COREInterface;

    public static void AddForceToSpring(UIntPtr springHandle, uint forceNodeHandle)
        IAnimatable spring = globalInterface.Animatable.GetAnimByHandle(springHandle);
        IINode forceNode = globalInterface.COREInterface.GetINodeByHandle(forceNodeHandle);

This doesn’t work either.