Notifications
Clear all

[Closed] get warning when calls 'skinops.getbonename'

Hi all:

I am trying to develop codes to find out all of the bones that a mesh uses. And then I want to find out the vertex that are managed by each bone.
But I failed at the first step. In fact, I wrote codes like:
sk = n.modifiers[#Skin]
number = skinops.getnumberbones sk
for i = 1 to number do
(
name = skinops.getbonename sk i 1
format “find bone $’%’
” name
)
But it fails to run and prompts a warning “Runtime error: Skin need to be selected and in the modifier panel Skin:Skin”.
Then I have to select the skin modifier and try again. Now the script works.
So, how can I avoid this manual selection of the skin modifier to let the script work without user intervention?
Thanks a lot!

2 Replies

first off – you’re assigning variables that are read-only… “number” and “name”, change these to something more unique, like “numBones” & “bnName”

secondly – what does the “n” variable represent?

if you’re looping through an array of meshes & “n” represents the current array item\position, then you’ll have to select it (which you can simply call “select n” in the script) – clunky & slow, but it works. i’m hoping there’s a more elegant solution i haven’t thought of…


 max modify mode --important! the below won't work unless you're in the modify tab
   for n in geometry do
   (
   	select n -- this selects the current object in the array
   	if n.modifiers != undefined do
   	(
   		if n.modifiers[#Skin] != undefined do
   		(
   			sk = n.modifiers[#Skin]
  			modPanel.setCurrentObject sk -- this selects the skin modifier
   			numBones = skinops.getnumberbones sk
   			for i = 1 to numBones do
   			(
   				bnName = skinops.getbonename sk i 1
   				format "find bone $%'
" bnName
   			)	
   		)
   	)
   )

Thanks for your help! It works now.