Page 1 of 1

Clone bones

Posted: Wed Jul 27, 2005 11:06 pm
by bogush_r
I wrote this script to compensate lack of copy/paste operations on bone objects. This script can duplicate selected bone with child bones. This is pre-alpha version with some restictions. For example, a bone can have more than one child bone, but only first children will be included in copy sequence (yet):

Code: Select all

P-+-A-+-B-+-C-
    \             
      +-a-+-b-

P has 2 children (A and a), but only P-A-B-C bones will be duplicated.

Another disadvantage is bones will be copied without keyframes.

I hope however, this tool can be useful. Anyway, all comments welcome.

http://bogush-r.narod.ru/moho/scripts/rb_clonebone.lua

Posted: Tue Aug 09, 2005 10:20 am
by genericdave
Seems a bit strange that this isn't part of the main moho package. Oh well, I guess that's why scripting is so great.

Anyway I was looking at your script and it seems like it would be pretty easy to make it clone all the selected bone's children. You could probably change the RB_CloneBone:Run() function so that it loops through the id of every bone in the skeleton and checks to see if it's a child of the selected bone instead of using the GetFirstChildBone() method. Something like this:

Code: Select all

function RB_CloneBone:Run(moho)
	local skel = moho:Skeleton()
	local parId = skel:SelectedBoneID()
	if parId == -1 then
		MESSAGE = 'Select a bone first'
		RB_CloneBoneMsg:new(moho):DoModal()
		return
	end


	local dlog = RB_CloneBoneDialog:new(moho)
	if (dlog:DoModal() == LM.GUI.MSG_CANCEL) then
		return
	end
	

-- Enum all child bones
	PARENT= -1
	Clone(moho:Skeleton(), parId)
	local numBones = skel:CountBones()
	for x = 1, numBones, 1 do	
		if skel:IsBoneParent(x, parId) then
			Clone(moho:Skeleton(), x)
		end
	end
end
Although for some reason this copies the entire skeleton instead of just the children. Pretty good for my first crack at moho scripting though.

Posted: Tue Aug 09, 2005 11:57 am
by Rai López
WOW!!! :shock: ...VEEERY USEFULL!!! THANKS! :D

PS: I always wonder me too why I could not do that with the main moho package, yes...