[Closed] MaxScript Noob, need help with addBones and select
Thanks for reading…
I usually script in MEL and have a programming background in C++ and Java, but I find myself needing to write a MaxScript for work and could use some help.
In this particular instance I have a file that has an animated biped in it. I am loading in a mesh and need to connect that mesh to the bones that are already in the file.
Right now I am using:
arrBones = $Bip_T_01* as array
for b in arrBones do
(
skinOps.addBone $.modifiers[#Skin] b 1
)
But I have a feeling this is not doing what I want because although the end result seems fine, I keep ending up with extra bones. They are nubs that have been added from helpers and what not. So I need to figure out either a different way to add the bones that are already in the file, or a way to turn off helpers during this process so I don’t end up with all the extra nubs.
I really appreciate your help – I’m sure I’ll be back with more questions
TC:
PS I am also having trouble generating code to select an obj that is stored in a variable.
I’ve tried:
objName = “$” + “’” + “Bip_T_01” + “’”
select objName
and
objName = “Bip_T_01”
select $objName
Neither work, they give me this
– No ““select”” function for “$‘Bip_T_01’”
or
– No ““select”” function for undefined
objName = “$” + “’” + “Bip_T_01” + “’”
select objName
and
objName = “Bip_T_01”
select $objName
Won’t work, nice try though, try instead
objName = $Bip_T_01
So close, I feel your pain.
One way to filter “non” bones is to check there class. Umm, something like
(isKindOf b BoneGeometry)
should return true only if the object is a “kind of bone”…okay, so that was kinda obvious, sorry.
It’s a little like “instanceof” in java.
Also have a look at…
classOf <value>
Returns the value’s class.
superClassOf <value>
Returns the value’s superclass. A value’s superclass is the class from which the value’s class was derived.
isKindOf <value> <class>
Returns true if value has given class or inherits from class.
Are you using the standard max bones or a character studio biped??
And lastly, welcome to the wonderful world of max script!
What you need here is:
objName = "Bip_T_01"
obj = getNodeByName objName
select obj
If you have a read through “Node Common Properties, Operators, and Methods” in the help, you’ll find a lot of useful utility functions for nodes.
Happy MaxScripting!
I’m using a character studio biped, well several of them in one file.
The script is based off of what character the user selects, and I couldn’t quite figure out how to pass a variable as an object name.
Oooh, beautiful!
[left]
objName = "Bip_T_01"[/left]
obj = getNodeByName objName
select obj
[left]Thanks so much to both of you for your replies. I really appreciate it![/left]
I can’t figure out how to apply this idea to mergemaxfile:
[left]objName = “Bip_T_01”[/left]
obj = getNodeByName objName
select obj
[left]since I can’t do “getNodeByName” for an object not in the file. I have a couple of work arounds but I am going to keep looking into the node reference for a simpler idea.[/left]
This one should be pretty simple. No workarounds needed!
v = point3 50 50 50
s = sphere pos:(random v -v)
t = teapot pos:(random v -v)
b = box pos:(random v -v)
names = #(s.name, t.name)
filename = "c:/temp/mergetest.max"
savemaxfile filename
max file new
mergeMAXFile filename names
Maybe I am misunderstanding, but what is happening here is this :
The user has loaded a file and selected a character, the script has loaded in a figure file for that character and then needs to merge another file that contains various resolution meshes. I only want it to merge the 8k mesh into the file it is working in. After this it does several more things in the original file the user opened. In your example… the script relies on being able to start up in the file that you are going to merge into your file, doesn’t it?
It doesn’t really matter to be honest with you; all that script does is create some objects to save then merge into an empty scene. The thing you need to be sure about is what mesh names are in the array passed to the function.
If you’re not sure, an array is formed like this:
#(value, value, value, …)
If you’re only replacing one node, then you only need one item in the array:
#(“mesh_8k”)
Perhaps you also need to append the keyword #deleteOldDups to the function to replace the original node?
I hope that gets you out of your tight spot.
Cheers,
Dave