Notifications
Clear all

[Closed] Add $ to arrays

I’ve tried this


arraytest = #("test1", "test2", "test3", "test4")

for i = 1 to arraytest.count do
	(
		arraytest[i][1] = "$T"
	)

but this only changes the array to :
“$est1”
“$est2”
“$est3”
“$est4”

My goal is to change it to :
“$Test1”
“$Test2”
“$Test3”
“$Test4”

Please any help is very much apreciated.

7 Replies

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

or

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.

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.

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
170
171
172

my verts as bitarray prints out
#{170…172}

not sure which I should use either.

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.

Any Ideas?

Ok I managed to get the bones to add

Ex:

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.

Nobody here likes skinops it seems? Everytime i mention them it gets quiet. :shrug: