[Closed] General Max script Problems – need help
hi ppl,
i’m facing few problems, during max script building, some of which might be basic, some not. but would like to get proper guidance… since the problems i encounter, seem to be so, only for me, not in other’s scripts !
- say i have my code :
curObj=(“$”+$.name)
– result : “$Sphere01”
and when i have to use this variable with a line like :
morName=curObj.modifiers[#Morpher]
–result : Unknown property: “modifiers” in “$Sphere01”
now what does this mean ? if i remove the prefix “$” in the curObj name, then also i get error saying unknown property in the Sphere01. i must be missing something, but what does max mean by “unknown property in the Sphere01” ??
i face similar problem when the above ‘curObj’ variable is used in conjunction with any command … everytime i make it a string and execute it, it works…but this is not the case
in other scripts that i have seen (like comet’s) …but one difference i notice is, in their scripts, they have used the variable combinations, which are defined in functions and these when fired, work fine, with out the error, using the SAME line of code. is this to be working only, when used in a function ? what if i dont have a need to define / use a function ? what if i only need some procedural lines to execute some task ?
- I’m tyring to do paramwiring of a sphere’s morpher with a spline curve’s X pos like so :
paramWire.connect2way $Sphere01.modifiers[#Morpher][#_1__Sphere02___No_Target_] $Circle01.pos.controller[#X_Position] "X_Position" "_1__Sphere02___No_Target_"
gives me this error : – Runtime error: connect requires subAnims… !
this above code is taken from the listener, when done manually , and i disconnect and use this code again to connect them and it fails… why is this so ? one thing i notice is, the name of the first morph target in the morpher modifier is >> “Sphere02” … but in the listener / param wire dialog it returns “1__Sphere02___No_Target” >> and when i use :
WM3_MC_GetName $Sphere01.modifiers[#morpher] 1
gives me : result : “Sphere02” …but then why is the underscore_version used ? even if i use this above code to get names of my morph targets and use that in my paramWire command it says ’ requires SubAnims’ … do the lines, maxscript listener spits out, different than what they actually are ?
i’ve been stuck at this morpher thing for almost a week now… and i am trying to make an interface which will help wiring of various sliders, with the chosen object’s tracks ( T or R or S or Morpher )…
any help is a boon !
-rgds,
- Read the MAXScript Reference FAQ – “How do I get the object by object name”.
You can imagine how often this is being asked if it landed on a FAQ list
In general, either use getNodeByName “Sphere01” or execute (“$”+theName), as “$Sphere01” is a string and not a path name.
- Don’t ever trust what the MacroRecorder says. It has nothing to do with real scripting. I have NEVER EVER turned the MacroRecorder on to learn something. If in trouble, read the MAXScript Reference or post here.
Will take a closer look at the wiring thing and try to post later…
Turns out the name expected for the subanim should be #_1__Sphere02___No_Target – without the last underscore.
(The underscore is still there in the last string though).
No idea why. Since the name changes dynamically as you delete targets (for example, in my test the name would be #_1__Sphere02___Target_Available), knowing that you want to use the first track of the Morpher, you can just say
paramWire.connect2way $Sphere01.Morpher[1] $Circle01.pos.controller[#X_Position] "X_Position" "_1__Sphere02___No_Target_"
The problem is that the Morpher was added in Max 3.0 based on Ishani’s Mix Modifier for R2, so it had no concept of wiring (which was added in R4) and behaves strangely when it comes to subanim naming. Using indexed access to subanims seems to cause less troubles in general…