PDA

View Full Version : Selecting bone, but wrong object.



walfridson
12-12-2007, 07:08 AM
Got two objects, Box (1) and Box (2). Both have a bone named bone01 in them and active.
I want lscript to select bone01 of Box (2).

SelectItem("Box (2)");
SelectItem("Bone01");

This selects Bone01 of Box (1)!

Any ideas?

dpont
12-12-2007, 08:47 AM
Except having different name for bones,
the other way need more steps,

scene = getfirstitem(SCENE);
get object ID with object name :

SelectByName("Box (2)");
objid = scene.firstSelect();

Get first bone:
nextBone = objid.bone();
Do a loop for all bones in this object:

while(nextBone)
{
if (nextbone.name == "Bone01")//Found we stop here
break;

//or we continue with next
nextBone = nextBone.next();
}

SelectItem(nextBone);

Not tested but this is the way.

Denis.

walfridson
12-12-2007, 09:44 AM
Thanks you Denis, I'll try that

walfridson
12-13-2007, 07:19 AM
Sorry, not working great..
I get "invalid argument 1 type SelectItem()" on SelectItem(nextBone);
Tested nextBone.name but as before bone01 of Box (1) gets selected.

dpont
12-13-2007, 07:35 AM
Yes, a typo error in a nextbone.name instead of
nextBone.name in the loop,
and SelectItem is for id not for name,
so use rather nextBone.id.
53066

Denis.

walfridson
12-13-2007, 07:43 AM
Yes, a typo error in a nextbone.name instead of
nextBone.name in the loop,
and SelectItem is for id not for name,
so use rather nextBone.id

Yes I fixed the typo before...
But .id made it work, thanks! :)