View Full Version : Add $ to arrays
04-08-2012, 05:08 PM
I've tried this
arraytest = #("test1", "test2", "test3", "test4")
for i = 1 to arraytest.count do
arraytest[i] = "$T"
but this only changes the array to :
My goal is to change it to :
Please any help is very much apreciated.
04-08-2012, 05:16 PM
what do you want to do? do you want to collect nodes by their names?
names = #("box01", "box02", "box04")
nodes = for name in names where isvalidnode (node = execute ("$'" + name + "'")) collect node
another way to get node by name is to use getNodeByName function
The real question is - do you want to have "$Test1", or the actual $Test1 object path in the array? I am not exactly sure why you would want a string containing $ in the array, so I had to ask.
Simplest way to do what you asked for:
for i = 1 to arraytest.count do arraytest[i] = "$"+arraytest[i]
since case does not play a role so "t" or "T" does not matter.
Alternative, much shorter
arraytest = for i in arraytest collect "$"+i
A more complex version of what you asked for:
for i = 1 to arraytest.count do arraytest[i] = "$T"+substring arraytest[i] 2 -1
arraytest = for i in arraytest collect "$T"+substring i 2 -1
What I *THINK* you might be asking for
arraytest = for i in arraytest collect getNodeByName i
This does not collect strings but the actual objects, or undefined if the object is not in the scene.
04-08-2012, 05:23 PM
Thank you both very much!
I have not tested it yet, but what I'm trying to do is to use the resulting array to add multiple bones, and I'm still not sure if I can use the array of bones to add them all, still have to test that as well.
04-08-2012, 05:40 PM
Oh I'll also be using it to weight the verts,
weightvalue1 = 1 / testarray.count
skinOps.SetVertexWeights skinMod unweightedverts \ ( testarray ) \ ( weightvalue1 )
hopefully i can use a array (unweightedverts) of the verts for <vertex_integer>
my verts as array prints
my verts as bitarray prints out
not sure which I should use either.
04-08-2012, 06:45 PM
Ok so I guess I need to get them as nodes, to add bones.
And also get them as bone ID's to add weight them to verts.
Cant seem to get them as nodes using the solution u mentioned Denis, I got and error:
-- Unable to convert: #("mEyeLeft", "mEyeRight", "mSkull") to type: String <<
and I've tried two of your solutions ("Simplest way to do what you asked for" and "What I *THINK* you might be asking for") , bobo but was unsucessfull to use the result to add bones but the second was able to be used to select the bones.
but when i try to use the result of what u think i meant, which is probably what i meant, but when i use that result to add bones by node i get this error:
-- Unable to convert: #($Editable_Mesh:mEyeLeft @ [0.073586,0.036000,1.761703], $Editable_Mesh:mEyeRight @ [0.073591,-0.036000,1.761703], $Editable_Mesh:mSkull @ [-0.024875,0.000000,1.761703]) to type: <node> <<
And I cant use skinOps.GetVertexWeightBoneID to get the ID because these are unweighted bones.
04-08-2012, 08:26 PM
Ok I managed to get the bones to add
unweighted = #("mEyeLeft", "mEyeRight", "mSkull")
for each in unweighted do
bone1 = (getNodeByName each)
if bone1 != undefined do
skinOps.addBone skinMod1 bone1 1
Still need to fina a way to get the ID's.
04-09-2012, 04:04 AM
Nobody here likes skinops it seems? Everytime i mention them it gets quiet. :shrug:
04-09-2012, 02:39 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.