- Рейтинг
- 7
Скрипт должен уметь находить, коллектить и переключать врэй прокси.
Потестируйте, пожалуйста. Может быть поможете улучшить.
Потестируйте, пожалуйста. Может быть поможете улучшить.
Код:
(--------------- start ProxySimplifier
--ScriptProxySimplifier_v1
--tested in Max 2013
rollout ProxySimplifier "ProxySimplifier"
( --start rollout ProxySimplifier
group "Finder:"
(
editText thePathText text:"Path is undefined" width:208 align:#left readOnly:true across:3
button btn_browse "<---- Browse" width:100 height:18 align:#right
button findMisProxy "Find Missing Proxies..." width:150 height:18 align:#right color:red
listbox mP "Wrong proxies:" height:10
label lbl_01 "------------------------------------------------------------" align:#center
button DoIt "Find Proxy..." width:150 height:18 align:#center
)
group "Collector:"
(
editText thePathText2 text:"Path is undefined" width:120 align:#center readOnly:true across: 4
button btn_browse2 "<---- Browse" width:100 height:18 align:#center
Checkbox chBox_update "Relink" width:60 align:#center checked:true
button DoIt2 "Collect Proxy..." width:120 height:18 align:#center color:red
)
group "Switcher:"
(
button btn3 "On" width:100 height:18 align:#center across: 3
button btn4 "Off" width:100 height:18 align:#center
Checkbox chBox2 "Selected only" width:60 align:#center checked:true
)
local theFolderPathCollector = undefined
local misProxyPathes = #()
local all_dir = #()
local theFolderPath = undefined
local theBooleanSwitch = true
--fn
fn exist_f the_path = try((getFiles the_path).count == 1)catch(undefined)
fn getFolderPathes root =
(
local dir_array = GetDirectories (root+"*")
join all_dir dir_array
if dir_array.count != 0 do
(
for the_path in dir_array do
(
join dir_array (GetDirectories the_path)
getFolderPathes the_path
)
)
return all_dir
)
fn KillMisProxies theProxy =
(
local theProxyPath = try(theProxy.filename)catch(undefined)
if theProxyPath != undefined and exist_f theProxyPath == false do
(
local theProxyName = fileNameFromPath theProxyPath
for folder in all_dir do
(
local theFiles = getFiles (folder + "*")
for file in theFiles do if (fileNameFromPath file) == theProxyName do theProxy.filename = file
)
)
)
--fn
--Switcher
on btn3 pressed do
(
if chBox2.state == true then for i in selected where classOf i == VrayProxy do (i.display = 1) else for i in objects where classOf i == VrayProxy do (i.display = 1)
)
on btn4 pressed do
(
if chBox2.state == true then for i in selected where classOf i == VrayProxy do (i.display = 0) else for i in objects where classOf i == VrayProxy do (i.display = 0)
)
--Switcher
--collector
on btn_browse2 pressed do
(
theFolderPathCollector= getSavePath caption: "Pick folder" initialDir:"C:\\"
thePathText2.text = theFolderPathCollector as string
)
on DoIt2 pressed do
(--start DoIt pressed
local theAllGoodProxy = #()
for i in objects do if classOf i == VRayProxy do
(
if exist_f i.filename == true do append theAllGoodProxy i
)
if theFolderPathCollector != undefined then
(
for i in theAllGoodProxy do
(
local theP1 = i.filename
local theP2 =theFolderPathCollector + "\\" + (filenameFromPath theP1)
try(copyFile theP1 theP2) catch(print ("don't copy - " + i.filename as string) )
if chBox_update.state == true do try(i.filename = theP2)catch()
)
)else messageBox "Please specify path."
)--end DoIt pressed
--end collector
on btn_browse pressed do
(
theFolderPath = getSavePath caption: "Pick folder" initialDir:"C:/"
thePathText.text = theFolderPath as string
)
on findMisProxy pressed do
(
misProxyPathes = #()
lbl_01.text = "Reading proxy..."
for i in objects do if classOf i == VRayProxy do
(
if exist_f i.filename == false do append misProxyPathes i.filename
try(lbl_01.text = i.name)catch()
)
mP.items = misProxyPathes
lbl_01.text = "please use DoubleClick for getting proxy"
)
on mP doubleClicked itm do
(
local the_obj = #(), the_array = #()
print misProxyPathes[itm] as string
for i in objects do if classOf i == VRayProxy do
(
if exist_f i.filename == false and misProxyPathes[itm] == i.filename do append the_obj i
try(lbl_01.text = i.name)catch()
)
select the_obj
lbl_01.text = "please use DoubleClick for getting proxy"
)
on DoIt pressed do
(
all_dir = #()
if theFolderPath != undefined then
(
lbl_01.text = "Reading pathes..."
getFolderPathes theFolderPath
for i in objects do
(
KillMisProxies i
try(lbl_01.text = i.name)catch()
)
lbl_01.text = "please use DoubleClick for getting proxy"
)
else messageBox "Please pick path..."
)
)--end rollout ProxySimplifier
CreateDialog ProxySimplifier 500 350
)------------- end ProxySimplifier