I'm a maya user moving to a studio using 3ds max.
I don't yet know the program very well, but if my assumptions are correct I think I may have run into a significant scripting bug already. I figured I'd bounce it off a forum for validation before I try to get autodesk support's attention. Is it a real bug? Am I expecting the wrong results? Is there an error in my debug attempt?
The following is a script which illustrates the bug. For reference, I am running Max 2009.
You can step through the script one chunk at a time to follow along, or just read through the dump when it's done.
For this case I've written the commentary as formats rather than comments, to make the output spew easier to read.
CODE
format "perhaps I've misunderstood how dependency is supposed to work in Max, but I was working under the assumption that in any case where one value is dependent on another,\nit should be possible to follow an immediateOnly dependency chain (however circuitous it might be) from one value to the other. if this is correct, I suppose I've found a bug."
format "first let's define a function to help illustrate the bug:\n"
fn jsConnectionReport obj =
(
dependencies = refs.dependsOn obj
immediateDependents = refs.dependents obj immediateOnly:true
allDependents = refs.dependents obj
format " % (%)\n dependencies:\n" (exprForMAXObject obj) obj
for dependency in dependencies do (format " % (%)\n" (exprForMAXObject dependency) dependency)
format " immediate dependents:\n"
for dependent in immediateDependents do (format " % (%)\n" (exprForMAXObject dependent) dependent)
format " all dependents:\n"
for dependent in allDependents do (format " % (%)\n" (exprForMAXObject dependent) dependent)
)
format "Now to begin : let's create a new cube, and call it 'A'\n"
A = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:1 width:1 height:1 mapcoords:off name:"A"
format "as expected, the bezier float controller for A's x position outputs to its position XYZ controller.\n"
jsConnectionReport A.position.controller.X_Position.controller
format "now let's add another box, 'B', and wire A.x to drive B.x\n"
B = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:1 width:1 height:1 mapcoords:off name:"B"
move B [0,2,0]
paramWire.connect A.pos.controller[#X_Position] B.pos.controller[#X_Position] "X_Position"
format "curiously, the A.x stops reporting the Position_XYZ controller as an immediate dependent when the output wire to B is added\ninstead, the wire itself now shows up as the only immediate dependent on A.x"
jsConnectionReport A.position.controller.X_Position.controller
format "if we check the A.position controller, it still thinks it is immediately dependent on A.x ... it's discouraging for them to disagree like this. (!!!)\n"
jsConnectionReport A.position.controller
format "out of curiosity, what happens if we delete B?\n"
select B
max delete
format "apparently the wire controller is left to wander the scene as an orphan, and A.x -still- sees the wire as its only immediate dependent\nluckily the scene still works, but as far as the refs interface is concerned A.x has forsaken its original obligation to provide for A.position_XYZ,\n and instead devotes its attention to the Float_Wire\n"
jsConnectionReport A.position.controller.X_Position.controller
format "just for reference, let's look at the Float_Wire\n"
the_Float_Wire = (refs.dependents A.position.controller.X_Position.controller immediateOnly:true)[1]
jsConnectionReport the_Float_Wire
format "as you can see, it's still driving the abandoned position_XYZ of box B... let's check that out : \n"
abandonedPXYZ = (refs.dependents the_Float_Wire immediateOnly:true)[1]
jsConnectionReport abandonedPXYZ
format "the XYZ is in turn still driving the abandoned PRS of box B... and there it's a dead end\n"
abandonedPRS = (refs.dependents abandonedPXYZ immediateOnly:true)[1]
jsConnectionReport abandonedPRS
format "confirming, as far as I can tell, that the immediateOnly dependency chain between A.x and A.position_XYZ was severed by the introduction of a wire to B,\nand trying to navigate from one to the other leads to a wild goose chase, particularly after B has been deleted\n"