Notifications
Clear all

[Closed] Changing string to array

I got the bones array from Skin Modify. So I wrote the list on tempBone.ini file.

After that, I wanted to apply the list again.


SkinBonesArray = (getINIsetting SkinedBoneArrayFile "SkinedBoneArray" "SkinedBoneArray")

But SkinBonesArray returned string value…

 
"#($Box:R_Clavicle_MidBone @ [-7.585646,2.286482,59.868385], ..........)" 

I used “execute” but it didn`t work.

How can I get it as array from .ini file?

2 Replies

You could parse the data you have there with filterString to just the name of the object but I would look into how you wrote the array to the .ini. You may want to a loop of the array when writing it to just write the names…

This is the function that gets Bones array.

 
 
fn GetSkinBonesArray = 
(
clearListener()
SkinBoneArray = #()
if (modPanel.getModifierIndex selection[1] selection[1].modifiers[#skin] ) != undefined do 
(
max modify mode
modPanel.setCurrentObject selection[1].modifiers[#skin]
for i=1 to (skinOps.GetNumberBones selection[1].modifiers[#skin]) do
( 
skinOps.SelectBone selection[1].modifiers[#skin] i
local TempBoneName = skinOps.GetBoneName selection[1].modifiers[#skin] i 1
local TempBone = getNodeByName TempBoneName
append SkinBoneArray TempBone
)
return SkinBoneArray
)
 
)
 

This is the script that writes it to .ini.

 
SkinedBoneArrayFile = @"C:\TempSkinedBoneArray.ini"
if (doesfileexist SkinedBoneArrayFile) then
(
setINIsetting SkinedBoneArrayFile "SkinedBoneArray" "SkinedBoneArray"((GetSkinBonesArray()) as string)
)
else 
(
crtTempINIfile = createfile SkinedBoneArrayFile
close crtTempINIfile
setINIsetting SkinedBoneArrayFile "SkinedBoneArray" "SkinedBoneArray"((GetSkinBonesArray()) as string)
)
 

This is the script that applies to new skin modifier again. From this part, we get the array from .ini as a string.

 
BonesArray = (getINIsetting SkinedBoneArrayFile "SkinedBoneArray" "SkinedBoneArray")
for i in BonesArray do
(
skinOps.addbone $[1].modifiers[#skin] i 1
)