--------------------------------------------------------------------------- -- *** KEYFRAME EXPORTER v0.95 *** --------------------------------------------------------------------------- -- Keyframe Data Export to AfterEffects 8.0 (CS4) -- based on AE Position Exporter by Aaron Dabelow (www.aarondabelow.com) -- -- written by Tonio Freitag (www.toniofreitag.com) --------------------------------------------------------------------------- -- exports Animated or Static Keyframes to AfterEffects -- --------------------------------------------------------------------------- try(destroyDialog AEKeyframeExporter)catch(print "fuck") ( -------------------- VARIABLE SETUP-------------------- local xPosAE local yPosAE local zPosAE local xRotAE local yRotAE local zRotAE local timerange = #range local currentPosition = "" local currentOrientation = "" ----------------------STRING SETUP------------------------ local headerText = "Adobe After Effects 8.0 Keyframe Data\n" local setupText = "\n\tUnits Per Second\t25\n\tSource Width\t1280\n\tSource Height\t720\n\tSource Pixel Aspect Ratio\t1\n\tComp Pixel Aspect Ratio\t1\n" local positionText = "\nTransform\tPosition\n\tFrame\tX pixels\tY pixels\tZ pixels" local orientationText = "\n\nTransform\tOrientation\n\tFrame\tX degrees" local returnText ="\n" local footerText = "\n\nEnd of Keyframe Data\n" local positionData = stringStream "" local orientationData = stringStream "" local dataText = stringStream "" ----------------------FUNCTIONS------------------------ function getCurrentData theObject = ( curFrame = ((currentTime as integer)/TicksPerFrame) as string xPosition = ((floor (theObject.pos.x * 1000)) / 1000) yPosition = ((floor (theObject.pos.y * 1000)) / 1000) zPosition = ((floor (theObject.pos.z * 1000)) / 1000) xPosAE = (xPosition) as string yPosAE = (-zPosition) as string zPosAE = (yPosition) as string xRotAE = ((-((theObject.rotation as eulerAngles).x) - 90) as string) yRotAE = (((theObject.rotation as eulerAngles).y) as string) zRotAE = (((theObject.rotation as eulerAngles).z) as string) currentPosition = "\n" + "\t" + curFrame + "\t" + xPosAE + "\t" + yPosAE + "\t" +zPosAE currentOrientation = "\n" + "\t" + curFrame + "\t"+ xRotAE + "\t" + yRotAE + "\t" + zRotAE ) function collectData switch progress status= ( dataText = stringStream "" if progress != unsupplied do ( progress.value = 0 progress.color = blue ) if selection.count == 1 then ( disableSceneRedraw() obj = $ copyObj = dummy position:[0,0,0] copyObj.name = obj.name + " [baked]" copyObj.pos.controller = Position_XYZ() format "%" positionText to:positionData format "%" orientationText to:orientationData if switch == #range do ( status.text = "collecting data..." now = sliderTime for i = animationrange.start to animationrange.end do ( animate on ( at time i (copyObj.transform = obj.transform) ) sliderTime = i getCurrentData copyObj print currentPosition print currentOrientation format "%" currentPosition to:positionData format "%" currentOrientation to:orientationData if progress != unsupplied do ( progress.value = 100.*i/((animationrange.end as integer)/192) ) ) sliderTime = now ) if switch == #frame do ( copyObj.transform = obj.transform getCurrentData copyObj format "%" currentPosition to:positionData format "%" currentOrientation to:orientationData ) delete copyObj format "%" headerText to:dataText format "%" setupText to:dataText format "%" (positionData as string) to:dataText format "%" (orientationData as string) to:dataText format "%" footerText to:dataText gotData = true enableSceneRedraw() ) else (messageBox "one object at a time!" title:"stupid") ) ----------------DEFINE ROLLOUT------------------ rollout AEKeyframeExporter "Export Keyframes to AE" width:200 ( group "current object" ( pickbutton bObject width: 135 height:20 ) group "export data" ( radiobuttons bSwitch labels:#("animation", "single frame") columns:2 button bCopyData " copy data " width:80 height:20 enabled:false button bSaveData " save data " width:80 height:20 enabled:false ) group "status" ( label lStatus "" progressbar prog ) group "notes" ( label lHint "works for 16:9 @ 25 fps" label lCam "" label lCam2 "" ) ---------------- ROLLOUT ACTIONS ------------------ on AEKeyframeExporter open do ( if selection.count == 1 then ( bObject.caption = $.name bCopyData.enabled = true bSaveData.enabled = true lStatus.text = "..." if superclassof $ == camera do ( lCam.text = "Angle Of View: " + ($.fov as string) lCam2.text = "turn off Auto Orientation!" ) ) else ( lStatus.text = "pick a single object!" bObject.caption = "pick!" ) ) on bObject picked obj do ( select obj dataText = stringStream "" positionData = "" orientationData = "" bObject.caption = obj.name bCopyData.enabled = true bSaveData.enabled = true lStatus.text = "..." ) on bSwitch changed state do ( bSwitch.state = state ) on bCopyData pressed do ( if selection.count ==1 then ( try ( if bSwitch.state == 1 do (timerange = #range) if bSwitch.state == 2 do (timerange = #frame) collectData timerange prog lStatus lStatus.text = "formatting data..." setclipboardText dataText lStatus.text = "copied to clipboard!" prog.color = green ) catch(Messagebox "Error") ) else (messagebox "You must select one (1) object") ) on bSaveData pressed do ( if selection.count == 1 then ( try ( saveForAEFileStaticName = GetSaveFileName filename:(maxFilePath + "AEKeyframeData_" + ($.name) + ".txt") types:"text(*.txt)" if saveForAEFileStaticName != undefined then ( saveForAEFileStatic = createfile saveForAEFileStaticName collectData timerange prog lStatus lStatus.text = "formatting data..." format "%" dataText to:saveForAEFileStatic close saveForAEFileStatic lStatus.text = "saved to file!" prog.color = green ) else() ) catch(Messagebox "Error") ) else (Messagebox "You must select one (1) object") ) ) --------------ROLLOUT CONSTRUCTION--------------- createDialog AEKeyframeExporter )