ScriptSpot

Forum topic · General Scripting

please help to uprgade useful script

By harumscarum · 2012-01-11

Description

here i had useful script to set render output filename directly from toolbar, but it is working only for PSD files. could anyone correct this script in order to set *.exr - V-Ray raw image file

<code>rollout psdmRoll "" width:320 height:34

(

fn get_psdm_index = (

local eff_index

for eff_index = 1 to numEffects do(

eff = getEffect eff_index

if (classOf(eff) == psd_manager) then return eff_index

)

return undefined

)--fn get_psdm_index

 

fn get_psdm_filename = (

local psdm_index = get_psdm_index()

if (psdm_index!=undefined) then return (getEffect psdm_index).filename

else return ""

)--fn get_psdm_filename

 

fn Set_psdm_filename fname = (

local psdm_index = get_psdm_index()

if (psdm_index!=undefined) then (getEffect psdm_index).filename = fname

)--fn Set_psdm_filename

 

fn Update = (

--print "Update"

psdmRoll.edt1.text = get_psdm_filename()

)--fn Update

 

 

button btn1 "psd" pos:[0,2] width:32 height:30 across:2

edittext edt1 "" pos:[32,4] width:264 height:19

 

on psdmRoll open  do(

Update()

callbacks.addScript #FilePostOpen "psdmRoll.Update()" id:#psdm_postOpen

)

 

on psdmRoll close  do(

callbacks.removeScripts #FilePostOpen id:#psdm_postOpen

)

 

on btn1 pressed  do(

local fname = getSaveFileName caption:"Save Photoshop Document As" filename:edt1.text types:"PSD(*.psd)|*.psd"

if (fname != undefined) then (

edt1.text = fname

Set_psdm_filename fname

)

)

 

on edt1 entered text do(

Set_psdm_filename text

)

)--rollout psdmRoll

 

 

CreateDialog psdmRoll

cui.RegisterDialogBar psdmRoll

cui.DockDialogBar psdmRoll #cui_dock_top 

 </code>

Comments (3)

Anubis · 2012-01-11

Who wrote this 'useful' script? Using

getSaveFileName()

is a bad idea in this case, use

selectSaveBitMap()

instead.

sets savepath..

jos · 2012-01-11

I do not understand exactly what you want, but maybe this is usefull..


fn setSave = ()

rollout savePath "" width:320 height:34
(
	
	edittext edt1 "" pos:[32,4] width:264 height:19
	button btnSave "..."  pos:[0,2]width:32 height:30 across:2

	on btnSave pressed  do
	(

		local fname = getSaveFileName caption:"Save file as" filename:edt1.text types:"JPG(*.jpg)|*.jpg|All Files(*.*)|*.*"

		if (fname != undefined) then 
		(
			edt1.text = fname
			setSave fname
		)

	)

	on edt1 entered text do ( setSave text )

)--end rollout

fn setSave filename = 
(
	rendSaveFile = true
	rendOutputFilename = filename
)

CreateDialog savePath
cui.RegisterDialogBar savePath
cui.DockDialogBar savePath #cui_dock_top 

harumscarum · 2012-01-11

thank you very much! in general it is working now. just put it in scripts/startup folder
and i adopted it to bottom bar (borderless toolbar) and for V-Ray raw image file output in EXR file.


(
local inipath = "$userScripts/harumscarum.ini"
local movingmode = false
local floatpos= execute (getinisetting inipath "savePath" "FloatPos")
local mousehitpoint


fn setSave = ()
 
rollout savePath "" width:214 height:22
(
 
	edittext edt1 "" pos:[0,1] width:180 height:19
	button btnSave "..." pos:[184,3] width:27 height:16 
	
	on btnSave pressed  do
	(
 
		local fname = getSaveFileName caption:"Save file as" filename:edt1.text types:"EXR(*.exr)|*.exr|All Files(*.*)|*.*"
 
		if (fname != undefined) then 
		(
			edt1.text = fname
			setSave fname
		)
 
	)
 
	on edt1 entered text do ( setSave text )
 
)--end rollout
 
fn setSave filename = 
(
	rendSaveFile = true
	renderers.current.output_rawFileName = filename
)

CreateDialog savePath pos:floatpos style:# ()
)

and simple code for harumscarum.ini


[savePath]
FloatPos=[1138,1148]

the only option i missing is Update. i mean when you load file SavePath script may show path from V-Ray raw image file output

thank you, Anubis
i will try to correct this script according your advice