Export bone position to After Effects &Particle Illusion

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
yambr
Posts: 2
Joined: Tue Apr 13, 2010 4:31 pm

Export bone position to After Effects &Particle Illusion

Post by yambr »

Script for exporting bone position form Anime Studionto After Effects & Particle Illusion

ct_export_bone_pos2ae.lua
http://www.aqwafilm.ru/files/ct_export_bone_pos2ae.lua

It works very simple. You choose one bone, and run the script. The script offers to create a file in the current directory. Enter any name and, most importantly, the extension of the text file. It is better to use ". txt". Next, open this file in any text editor, highlight all and copy to the clipboard. These datas can be inserted in After Effects (in the track position), and in Particle Illusion (the position of the emitter).

The current version of the script is 0.2. Although it works without errors, the functionality not quite satisfied me. For example, I do not know how to access to the clipboard from lua script. Therefore I introduced an extra step with a text file. The script has been tested only in Anime Studio 5.6.

The script was written during the creation of an animated movie "Brave Gonza", as well as several other useful scripts. For example, this script was used to create the first episode of the film, the animation of smoke and fire dragons. http://www.youtube.com/watch?v=kXUFyeVN5R0
Last edited by yambr on Tue Apr 13, 2010 8:33 pm, edited 1 time in total.
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Great! I'll use this script a lot with AE.
It would be awesome if you could post the other scripts you made. If you want :roll:

Thanks!
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Re: Export bone position to After Effects &Particle Illu

Post by Rudiger »

Wow, that animation was a wonderful piece of art. Well done!
yambr wrote:The current version of the script is 0.2. Although it works without errors, the functionality not quite satisfied me. For example, I do not know how to access to the clipboard from lua script. Therefore I introduced an extra step with a text file. The script has been tested only in Anime Studio 5.6.
I have been able to get access to the clipboard from within Lua in the Windows version of AnimeStudio by using the require statement with a cute little custom dll file.

However, if you are using a Mac I don't think I can help you, as I once tried to get it to work for a friend who had a Mac but was foiled at every turn! It seems that the Mac version of AS doesn't support the require or popen functions so you're stuck with using os.execute and I just couldn't seem to get access to the global clipboard through my command-line program, no matter what I tried.

It was awkward, though, since I didn't have a Mac to try it on and kept having to resend different versions to my friend to try out.
madriver
Posts: 101
Joined: Fri Dec 22, 2006 6:11 am

Post by madriver »

Nice animation! And thank you for the script!
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

I never saw this script before now! It would be REALLY useful is someone could add bone rotation into the mix? *bats eyes* :wink:
ponysmasher
Posts: 370
Joined: Thu Aug 05, 2004 2:23 am
Location: Los Angeles
Contact:

Post by ponysmasher »

funksmaname wrote:I never saw this script before now! It would be REALLY useful is someone could add bone rotation into the mix? *bats eyes* :wink:
Does it have to be bones? Because I just realised I never uploaded my "Export layer to After Effects" script. You'll get motion in XYZ, rotation in XYZ and even opacity.

For total accuracy you can use my Export camera to AE script.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

Yeah - I redownloaded your camera script earlier as I've got a project I might need it on. It's great!

It doesn't have to be bones - as long as a null ends up with the same movement and rotation - thanks for that! :)
jackbenimble
Posts: 1
Joined: Wed Jul 13, 2011 11:37 pm

Post by jackbenimble »

I would also love for the bone export script to register rotation values. Regardless, thanks so much for posting this!
Cg_krop
Posts: 1
Joined: Fri Oct 18, 2013 6:49 pm

Re: Export bone position to After Effects &Particle Illusion

Post by Cg_krop »

Hi, I know this post is a bit old, but I am working in a project and have animated a character in anime studio 9, but the rest of the project has been made in after effects, I would like to export my animated character to AE but not like a movie, to avoid loosing quality, but export the movements of the bone layer. Is it possible? I tried to download your script to try it, but it is not available anymore. Thanks a lot!
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Export bone position to After Effects &Particle Illusion

Post by Víctor Paredes »

Hello. as anyone a backup of this script? I can't find it anymore.
Thanks!
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
Rai López
Posts: 2228
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: Export bone position to After Effects &Particle Illusion

Post by Rai López »

Víctor Paredes wrote: Fri Mar 16, 2018 5:39 pm Hello. as anyone a backup of this script? I can't find it anymore.

Hi. I just ended up into this thread, checked it just in case and, indeed, I found a copy of this script from yambr (thanks!) in my hard drive. Surely to late... but here it is just in case someone still need it or whatever:

Code: Select all

-- **************************************************
-- Provide Moho with the name of this scriipt object
-- ***************************************************

ScriptName = "CT_EXPORT_BONE_POS_2_AE"

-- ***************************************************
-- General information about this script
-- ***************************************************

CT_EXPORT_BONE_POS_2_AE = {}

function CT_EXPORT_BONE_POS_2_AE:Name()
    return "CT_EXPORT_BONE_POS_2_AE"
end

function CT_EXPORT_BONE_POS_2_AE:Version()
    return "0.2"
end

function CT_EXPORT_BONE_POS_2_AE:Description()
    return "Expost select bone position 2 After Effects"
end

function CT_EXPORT_BONE_POS_2_AE:Creator()
    return "Ilya Suvorkin"
end

function CT_EXPORT_BONE_POS_2_AE:UILabel()
    return "Expost Bone position 2 After Effects " .. CT_EXPORT_BONE_POS_2_AE:Version()
end

-- ***************************************************
-- Recurring values
-- ***************************************************




-- ***************************************************
-- The guts of this script
-- ***************************************************

function CT_EXPORT_BONE_POS_2_AE:IsEnabled(moho)

    if ( layerCount == 0 ) then
        return
    end
    
   if ( moho.layer:IsBoneType() ~=true) then
    	return
    end

 local skel = moho:Skeleton()
	if (skel == nil) then
		return false
	end
	if (skel:CountBones() < 1) then
		return false
	end
	return true
end

function CT_EXPORT_BONE_POS_2_AE:Run(moho)
    local path

    local endFrame
	local beginFrame

	local m = LM.Matrix:new_local()
	local vec = LM.Vector3:new_local()
	local oldVec = LM.Vector3:new_local()
	local origin = moho.layer:Origin()


   	local origin = LM.Vector2:new_local()
	local tmporigin = LM.Vector2:new_local()
	local tip = LM.Vector2:new_local()
    local oldorigin = LM.Vector2:new_local()
	local oldtip = LM.Vector2:new_local()

	local matrix = LM.Matrix:new_local()

    local bone
    local curbone
    


    if ( layerCount == 0 ) then
        return
    end


    local layer        = moho.layer
    local layerType    = layer:LayerType()

    if ( layer:IsBoneType() ~=true) then
    	return
    end

    local skel = moho:Skeleton()
    local boneCount
    local i

    if ( skel == nil ) then
        return
    end

    path = LM.GUI.SaveFile("Animation Data File");
    if ( path == "" ) then
        return
    end

    CT_EXPORT_BONE_POS_2_AE.file = io.open( path, "w" )
    if ( CT_EXPORT_BONE_POS_2_AE.file == nil ) then
        print( "Could not open file");
        return
    end


    boneCount = skel:CountBones()

    if ( boneCount < 1 ) then
        return
    end


 	
    for i = 0, boneCount-1 do
        local bone = skel:Bone( i )


	   	
		if (bone.fSelected) then
				curbone=bone
				width=moho.document:Width()
				height=moho.document:Height()
				fps=moho.document:Fps()
   				aspect=moho.document:AspectRatio()

				unit= height/2

            	CT_EXPORT_BONE_POS_2_AE.file:write("Adobe After Effects 6.5 Keyframe Data\n\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\tUnits Per Second\t" .. fps .. "\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\tSource Width\t" .. width .."\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\tSource Height\t" .. height .."\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\tSource Pixel Aspect Ratio\t1\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\tComp Pixel Aspect Ratio\t1\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("Position\n")
            	CT_EXPORT_BONE_POS_2_AE.file:write("\tFrame\tX pixels\tY pixels\tZ pixels\n")

	       		beginFrame=1
				endFrame=moho.document:EndFrame()
				for frame = beginFrame, endFrame do

             		moho:SetCurFrame(frame)

		           	moho.layer:GetFullTransform(frame, matrix, moho.document)
		            tip:Set(curbone.fLength,0)  --äëèíà êîñòè!!
		            curbone.fMovedMatrix:Transform(tip)
		            matrix:Transform(tip)
		            
           			CT_EXPORT_BONE_POS_2_AE.file:write("\t"..frame .. "\t" .. unit*(tip.x+aspect) .. "\t".. unit*(1-tip.y) .. "\t0\n")

			 	end

				CT_EXPORT_BONE_POS_2_AE.file:write("\n\nEnd of Keyframe Data\n")
				CT_EXPORT_BONE_POS_2_AE.file:close()
		end
	end
end

...
User avatar
DK
Posts: 2849
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: Export bone position to After Effects &Particle Illusion

Post by DK »

Does anyone know what version of Particle Illusion this script supports?
Cheers
D.K
Post Reply