[Closed] [SOLVED] Clicking "Convert" button in V-Ray scene converter, possible bug
Hello everyone !
I’m writing a script to Automatically convert Corona scenes to V-ray, I’ve written this but it doesn’t click the “Convert” button and when I do (manually) it bugs the whole 3ds Max 2016 session. I must restart it.
How can it be fixed ?
macros.run "VRay" "VRaySceneConverter"
fn ClickConvert =
(
local hwnd = dialogMonitorOps.getWindowHandle();
try
(
if uiAccessor.getWindowText hwnd == "V-Ray scene converter" do uiAccessor.pressButtonByName hwnd "Convert";
true;
)
catch
(
false;
)
dialogMonitorOps.enabled = true ;
dialogMonitorOps.interactive = false;
)
ClickConvert()
actionMan.executeAction 0 "63545" -- Views: Viewport Materials Display as Shaded with Maps
-
You’re calling “ClickConvert” after the Vray dialog pops up, so the dialog monitor is not catching the new window event.
-
Always disable the dialogmonitor after using it. Can lead to weird behavior otherwise, in my experience.
This works for me:
fn ClickConvert =
(
local hwnd = dialogMonitorOps.getWindowHandle();
try
(
if uiAccessor.getWindowText hwnd == "V-Ray scene converter" do uiAccessor.pressButtonByName hwnd "Convert";
true;
)
catch
(
false;
)
dialogMonitorOps.enabled = true ;
dialogMonitorOps.interactive = false;
)
ClickConvert()
macros.run "VRay" "VRaySceneConverter"
actionMan.executeAction 0 "63545" -- Views: Viewport Materials Display as Shaded with Maps
dialogMonitorOps.enabled = false
Thank you for your quick answer, unfortunately the script doesn’t work for me I tried it on multiple Corona Max files. Are you sure your materials are changed/ scene converted ?
To complete the script, I also added the Renderer Assignment to Vray but I couldn’t figure out how to collect the materials in Material Slot.
fn ClickConvert =
(
local hwnd = dialogMonitorOps.getWindowHandle();
try
(
if uiAccessor.getWindowText hwnd == "V-Ray scene converter" do uiAccessor.pressButtonByName hwnd "Convert";
true;
)
catch
(
false;
)
dialogMonitorOps.enabled = true ;
dialogMonitorOps.interactive = false;
)
ClickConvert()
macros.run "VRay" "VRaySceneConverter"
actionMan.executeAction 0 "63545" -- Views: Viewport Materials Display as Shaded with Maps
actionMan.executeAction 0 "550" -- Views: Viewport Visual Style Shaded
dialogMonitorOps.enabled = false
renderers.current = Vray()
macros.run "Medit Tools" "clear_medit_slots"
EDIT: I just tried on Max 2017, it doesn’t work either
it has to be:
(
fn ClickConvert =
(
hwnd = DialogMonitorOPS.GetWindowHandle()
if (UIAccessor.GetWindowText hwnd) == "V-Ray scene converter" do
(
UIAccessor.PressButtonByName hwnd "Convert"
actionMan.executeAction 0 "63545" -- Views: Viewport Materials Display as Shaded with Maps
actionMan.executeAction 0 "550" -- Views: Viewport Visual Style Shaded
)
true
)
DialogMonitorOPS.RegisterNotification ClickConvert id:#PokeVRaySceneConverter
DialogMonitorOPS.Enabled = true
try (macros.run "VRay" "VRaySceneConverter") catch()
DialogMonitorOPS.unRegisterNotification id:#PokeVRaySceneConverter
DialogMonitorOPS.Enabled = false
ok
)
I don’t have VRay, so I can’t test it…
Thank you Denis ! It works perfectly now ! You’re a Boss !
I added the Renderer assignement to Vray and the ability to collect all the converted Vray materials in Editor :
(
fn ClickConvert =
(
hwnd = DialogMonitorOPS.GetWindowHandle()
if (UIAccessor.GetWindowText hwnd) == "V-Ray scene converter" do
(
UIAccessor.PressButtonByName hwnd "Convert"
actionMan.executeAction 0 "63545" -- Views: Viewport Materials Display as Shaded with Maps
actionMan.executeAction 0 "550" -- Views: Viewport Visual Style Shaded
)
true
)
DialogMonitorOPS.RegisterNotification ClickConvert id:#PokeVRaySceneConverter
DialogMonitorOPS.Enabled = true
try (macros.run "VRay" "VRaySceneConverter") catch()
DialogMonitorOPS.unRegisterNotification id:#PokeVRaySceneConverter
DialogMonitorOPS.Enabled = false
ok
)
renderers.current = Default_scanline_renderer ()
renderers.current = Vray()
macros.run "Medit Tools" "clear_medit_slots"
mats = for m in scenematerials collect m
for i= 1 to 24 do (
if mats[i] != undefined then meditMaterials[i] = mats[i]
)