Page 1 of 1

Export bone position to After Effects &Particle Illusion

Posted: Tue Apr 13, 2010 5:29 pm
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

Posted: Tue Apr 13, 2010 7:48 pm
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!

Re: Export bone position to After Effects &Particle Illu

Posted: Fri Apr 16, 2010 3:45 am
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.

Posted: Tue Jun 01, 2010 5:19 pm
by madriver
Nice animation! And thank you for the script!

Posted: Tue Jul 12, 2011 12:46 am
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:

Posted: Tue Jul 12, 2011 8:25 am
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.

Posted: Tue Jul 12, 2011 8:36 am
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! :)

Posted: Wed Jul 13, 2011 11:38 pm
by jackbenimble
I would also love for the bone export script to register rotation values. Regardless, thanks so much for posting this!

Re: Export bone position to After Effects &Particle Illusion

Posted: Fri Oct 18, 2013 8:15 pm
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!

Re: Export bone position to After Effects &Particle Illusion

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

Re: Export bone position to After Effects &Particle Illusion

Posted: Sun Jan 09, 2022 8:03 pm
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


Re: Export bone position to After Effects &Particle Illusion

Posted: Mon Jan 10, 2022 11:05 am
by DK
Does anyone know what version of Particle Illusion this script supports?
Cheers
D.K