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

ScriptName = "SZ_CurrentFrameToPng"

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

SZ_CurrentFrameToPng = {}

function SZ_CurrentFrameToPng:Name()
	return self:Localize('UILabel')
end

function SZ_CurrentFrameToPng:Version()
	return '1.0'
end

function SZ_CurrentFrameToPng:UILabel()
	return self:Localize('UILabel')
end

function SZ_CurrentFrameToPng:Creator()
	return 'Stan'
end

function SZ_CurrentFrameToPng:Description()
	return self:Localize('Description')
end

-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************

function SZ_CurrentFrameToPng:IsRelevant(moho)
	return true
end

function SZ_CurrentFrameToPng:IsEnabled(moho)
	return true
end

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

SZ_CurrentFrameToPng.folder = 'C:\\moho-frames'

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

function SZ_CurrentFrameToPng:Run(moho)
	local timestamp = os.date("%Y-%m-%d_%H-%M-%S")
	local fileName = string.format('Frame %s - %s.png', moho.frame, timestamp)
	local fullPath = self.folder .. '\\' .. fileName
	os.execute('mkdir -p "' .. self.folder .. '"')
	moho:FileRender(fullPath)
	io.popen('start "" "' .. self.folder .. '"')
	-- print(self:Localize('Saved') .. fullPath)
end

-- **************************************************
-- Localization
-- **************************************************

function SZ_CurrentFrameToPng:Localize(text)
	local phrase = {}

	phrase['Description'] = 'Renders current frame to a .png file'
	phrase['UILabel'] = 'Current Frame to PNG'
	phrase['Saved'] = 'Saved file '


	local fileWord = MOHO.Localize("/Menus/File/File=File")
	if fileWord == "Файл" then
		phrase['Description'] = 'Рендерит текущий кадр в .png'
		phrase['UILabel'] = 'Текущий кадр в PNG'
		phrase['Saved'] = 'Сохраненный файл: '
	end

	return phrase[text]
end

Icon
Current Frame to PNG
Listed

Author: Stan View Script
Script type: Button/Menu

Uploaded: Dec 23 2020, 19:09

Renders the current frame and saves it as a PNG (with transparency). The same as if you hit Ctrl+R and use the "Save as PNG", but in a single click.
Image

Installation Options:

This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 50