I have tried (quite: true)......but it stops there....I want the render to "continue" while skipping that message. Any solution?
Forum topic · General Scripting
How to skip (continue) missing map warning while rendering
By Goonda · 2012-09-18
Description
Comments (8)
Goonda · 2012-09-21
Here the script:
(
renderers.production = Default_Scanline_Renderer ()
(
select geometry
local matnew= standardMaterial showInViewport:true
$.mat = matnew
matnew.name = "New"
clearselection()
gc()
freeSceneBitmaps()
)
global thePathSS = "C:\\"
rollout nm "Normal_Map" width:194 height:424
(
pickbutton btn_high "High_Poly" pos:[60,24] width:68 height:20 enabled: false
label lbl_high "select the highpoly mesh" pos:[26,50] width:135 height:17
pickbutton btn_low "Low_Poly" pos:[59,76] width:72 height:21 enabled:false
label lbl_low "select the low poly mesh" pos:[25,103] width:144 height:20
GroupBox grp1 "Select Meshes" pos:[8,8] width:176 height:119
button btn_path "Select Path" pos:[56,165] width:80 height:32
label lbl_path "C:\\" pos:[16,203] width:160 height:16
GroupBox grp2 "Path" pos:[8,153] width:176 height:72
dropdownList ddl_dimension "Dimension" pos:[13,235] width:171 height:40 items:#("32", "64", "128", "256", "512", "1024", "2048", "4096")
radiobuttons qualrad "" pos:[29,305] width:118 height:32 labels:#("low", "medium", "high", "best") columns:2
GroupBox grp3 "Quality" pos:[9,283] width:175 height:64
checkbox chk_auto " Auto Unwrap" pos:[37,133] width:120 height:16
button btn_render "Render" pos:[44,383] width:101 height:29
spinner spn_cagedist "" pos:[110,355] width:52 height:16 range:[-100,100,2]
label lbl_cagedist "Cage Distance:" pos:[28,355] width:78 height:22
on btn_high picked o do
(
if superclassof o == geometryclass and classof o != bonegeometry then
(
lbl_high.text = o.name
select o
global highpoly = o
)
else
(
messagebox "Select a mesh" title: "Wrong Selection" beep:true
)
)
on btn_low picked obj do
(
if superclassof obj == geometryclass and classof obj != bonegeometry then
(
lbl_low.text = obj.name
select obj
global lowpoly = obj
)
else
(
messagebox "Select a mesh" title: "Wrong Selection" beep:true
)
)
on btn_path pressed do
(
global thePathSS = getSavepath()
if thePathSS != undefined then
(
lbl_path.text = thePathSS
btn_low.enabled = true
btn_high.enabled = true
)
else
(
messagebox "No path defined" title: "Path Not Defined" beep:true
)
)
fn unwrapNormAuto obj =
(
flattenAngle = 45.0
flattenSpacing = 0.02
flattenRotate = true
flattenFillHoles = true
unwrapMod = unwrap_UVW()
unwrapMod.setAlwaysEdit false
unwrapMod.setMapChannel 1
unwrapMod.setFlattenAngle flattenAngle
unwrapMod.setFlattenSpacing flattenSpacing
unwrapMod.setFlattenNormalize true
unwrapMod.setFlattenRotate flattenRotate
unwrapMod.setFlattenFillHoles flattenFillHoles
unwrapMod.setApplyToWholeObject true
unwrapMod.name = "Automatic Flatten UVs"
unwrapMod.setDebugLevel 0
setAppData unwrapMod 0x41dd73d5 #object
addModifier obj unwrapMod
unwrapMod.flattenMapByMatID flattenAngle flattenSpacing true 2 flattenRotate flattenFillHoles
)
fn bakeNorm =
(
size = ddl_dimension.selected as integer
cagedistance = spn_cagedist.value
ambientColor = color 255 255 255
converttopoly lowpoly
local theProj = ProjectionMod()
theProj.addObjectNode highpoly
theProj.autowrapCage()
theProj.resetCage()
theProj.pushCage cagedistance
theProj.addRegisteredProjectionType 1
theProj.projectProjectionType 1
theProj.ignoreBackfacing = true
addModifier lowpoly theProj
lowpoly.iNodeBakeProperties.removeAllBakeElements()
lowpoly.INodeBakeProperties.bakeEnabled = true
lowpoly.INodeBakeProperties.bakeChannel = 1
lowpoly.INodeBakeProperties.nDilations = 4
macros.run "Render" "BakeDialog"
wascancelled = false
local be1 = NormalsMap()
be1.outputSzX = be1.outputSzY = size
be1.fileType = (thePathSS+"\\"+lowpoly.name+"_"+highpoly.name+"_normal.png")
be1.fileName = filenameFromPath be1.fileType
be1.enabled = true
be1.useNormalBump = true
be1.targetMapSlotName = "diffuse"
lowpoly.INodeBakeProperties.addBakeElement be1
local NormDiff = bitmaptexture filename:be1.fileType
lowpoly.material = standardmaterial diffuseMap:NormDiff showInViewport:true
local vfb = render rendertype:#bakeSelected outputwidth:size outputheight:size cancelled:&wascancelled quiet:true
for obj in geometry do
(
m = obj.modifiers.count
for i=1 to m do
(
for m in obj.modifiers do
(
if classOf m==Project_Mapping_Holder do deleteModifier obj m
)
)
)
deletemodifier lowpoly 1
try ( destroyDialog gTextureBakeDialog)catch()
close vfb
completeRedraw()
freeSceneBitmaps()
gc()
global thePathSS = "C:\\"
destroydialog nm
)
fn qual =
(
case qualrad.state of
(
1: (renderers.production.globalSamplerEnabled = false; renderers.production.globalSamplerClassByName = "Max 2.5 Star"; renderers.production.globalSamplerQuality = 0.1 ; scanlinerender.antiAliasfilter = Area())
2: (renderers.production.globalSamplerEnabled = true ; renderers.production.globalSamplerClassByName = "Max 2.5 Star"; renderers.production.globalSamplerQuality = 0.1; scanlinerender.antiAliasfilter = Area())
3: (renderers.production.globalSamplerEnabled = true; renderers.production.globalSamplerClassByName = "Hammersley"; renderers.production.globalSamplerQuality = 0.5; scanlinerender.antiAliasfilter = Area())
4: (renderers.production.globalSamplerEnabled = true; renderers.production.globalSamplerClassByName = "Hammersley"; renderers.production.globalSamplerQuality = 1.0; scanlinerender.antiAliasfilter = Catmull_Rom())
)
)
on btn_render pressed do
(
if chk_auto.checked == false then
(
qual()
bakeNorm()
)
else
(
qual()
unwrapNormAuto lowpoly
bakeNorm()
)
)
)
createDialog nm
)
MKlejnowski · 2012-09-23
This should fix your issue. Its not a clean fix but i found it useful for occasion like this. I figured you just want the default button to be pressed so i just pulled some code i found online a while back. Couldn't tell you where i got it but i know i saved it. It uses
dialogMonitorOpsand
uiAccessorto pretty interact with UI dialogs that come up. I would love to explain in more detail how it works but I just know it works and haven't really dabbled in it to deeply to have a keen understanding of it but this should fix your issue ATM
here is your new code with it implemented
(
renderers.production = Default_Scanline_Renderer ()
(
select geometry
local matnew= standardMaterial showInViewport:true
$.mat = matnew
matnew.name = "New"
clearselection()
gc()
freeSceneBitmaps()
)
global thePathSS = "C:\\"
rollout nm "Normal_Map" width:194 height:424
(
pickbutton btn_high "High_Poly" pos:[60,24] width:68 height:20 enabled: false
label lbl_high "select the highpoly mesh" pos:[26,50] width:135 height:17
pickbutton btn_low "Low_Poly" pos:[59,76] width:72 height:21 enabled:false
label lbl_low "select the low poly mesh" pos:[25,103] width:144 height:20
GroupBox grp1 "Select Meshes" pos:[8,8] width:176 height:119
button btn_path "Select Path" pos:[56,165] width:80 height:32
label lbl_path "C:\\" pos:[16,203] width:160 height:16
GroupBox grp2 "Path" pos:[8,153] width:176 height:72
dropdownList ddl_dimension "Dimension" pos:[13,235] width:171 height:40 items:#("32", "64", "128", "256", "512", "1024", "2048", "4096")
radiobuttons qualrad "" pos:[29,305] width:118 height:32 labels:#("low", "medium", "high", "best") columns:2
GroupBox grp3 "Quality" pos:[9,283] width:175 height:64
checkbox chk_auto " Auto Unwrap" pos:[37,133] width:120 height:16
button btn_render "Render" pos:[44,383] width:101 height:29
spinner spn_cagedist "" pos:[110,355] width:52 height:16 range:[-100,100,2]
label lbl_cagedist "Cage Distance:" pos:[28,355] width:78 height:22
on btn_high picked o do
(
if superclassof o == geometryclass and classof o != bonegeometry then
(
lbl_high.text = o.name
select o
global highpoly = o
)
else
(
messagebox "Select a mesh" title: "Wrong Selection" beep:true
)
)
on btn_low picked obj do
(
if superclassof obj == geometryclass and classof obj != bonegeometry then
(
lbl_low.text = obj.name
select obj
global lowpoly = obj
)
else
(
messagebox "Select a mesh" title: "Wrong Selection" beep:true
)
)
on btn_path pressed do
(
global thePathSS = getSavepath()
if thePathSS != undefined then
(
lbl_path.text = thePathSS
btn_low.enabled = true
btn_high.enabled = true
)
else
(
messagebox "No path defined" title: "Path Not Defined" beep:true
)
)
fn unwrapNormAuto obj =
(
flattenAngle = 45.0
flattenSpacing = 0.02
flattenRotate = true
flattenFillHoles = true
unwrapMod = unwrap_UVW()
unwrapMod.setAlwaysEdit false
unwrapMod.setMapChannel 1
unwrapMod.setFlattenAngle flattenAngle
unwrapMod.setFlattenSpacing flattenSpacing
unwrapMod.setFlattenNormalize true
unwrapMod.setFlattenRotate flattenRotate
unwrapMod.setFlattenFillHoles flattenFillHoles
unwrapMod.setApplyToWholeObject true
unwrapMod.name = "Automatic Flatten UVs"
unwrapMod.setDebugLevel 0
setAppData unwrapMod 0x41dd73d5 #object
addModifier obj unwrapMod
unwrapMod.flattenMapByMatID flattenAngle flattenSpacing true 2 flattenRotate flattenFillHoles
)
fn bakeNorm =
(
size = ddl_dimension.selected as integer
cagedistance = spn_cagedist.value
ambientColor = color 255 255 255
converttopoly lowpoly
local theProj = ProjectionMod()
theProj.addObjectNode highpoly
theProj.autowrapCage()
theProj.resetCage()
theProj.pushCage cagedistance
theProj.addRegisteredProjectionType 1
theProj.projectProjectionType 1
theProj.ignoreBackfacing = true
addModifier lowpoly theProj
lowpoly.iNodeBakeProperties.removeAllBakeElements()
lowpoly.INodeBakeProperties.bakeEnabled = true
lowpoly.INodeBakeProperties.bakeChannel = 1
lowpoly.INodeBakeProperties.nDilations = 4
macros.run "Render" "BakeDialog"
wascancelled = false
local be1 = NormalsMap()
be1.outputSzX = be1.outputSzY = size
be1.fileType = (thePathSS+"\\"+lowpoly.name+"_"+highpoly.name+"_normal.png")
be1.fileName = filenameFromPath be1.fileType
be1.enabled = true
be1.useNormalBump = true
be1.targetMapSlotName = "diffuse"
lowpoly.INodeBakeProperties.addBakeElement be1
local NormDiff = bitmaptexture filename:be1.fileType
lowpoly.material = standardmaterial diffuseMap:NormDiff showInViewport:true
dialogMonitorOps.unRegisterNotification id:#test
fn checkDialog =
(
local hwnd = dialogMonitorOps.getWindowHandle()
if (hwnd == 0) then ( false )
else (
format "==================================================\n"
format "%\n" hwndText
local children = uiAccessor.getChildWindows hwnd
format "--------------------------------------------------\n"
for child in children do (
format "%\n" (uiAccessor.getWindowText child)
)
format "==================================================\n"
uiAccessor.pressDefaultButton()
true
)
)
dialogMonitorOps.enabled = true
dialogMonitorOps.interactive = false
dialogMonitorOps.registerNotification checkDialog id:#test
local vfb = render rendertype:#bakeSelected outputwidth:size outputheight:size cancelled:&wascancelled --quiet:true
dialogMonitorOps.enabled = false
dialogMonitorOps.unRegisterNotification id:#test
--UIAccessor.GetWindowText
for obj in geometry do
(
m = obj.modifiers.count
for i=1 to m do
(
for m in obj.modifiers do
(
if classOf m==Project_Mapping_Holder do deleteModifier obj m
)
)
)
deletemodifier lowpoly 1
try ( destroyDialog gTextureBakeDialog)catch()
close vfb
completeRedraw()
freeSceneBitmaps()
gc()
global thePathSS = "C:\\"
destroydialog nm
)
fn qual =
(
case qualrad.state of
(
1: (renderers.production.globalSamplerEnabled = false; renderers.production.globalSamplerClassByName = "Max 2.5 Star"; renderers.production.globalSamplerQuality = 0.1 ; scanlinerender.antiAliasfilter = Area())
2: (renderers.production.globalSamplerEnabled = true ; renderers.production.globalSamplerClassByName = "Max 2.5 Star"; renderers.production.globalSamplerQuality = 0.1; scanlinerender.antiAliasfilter = Area())
3: (renderers.production.globalSamplerEnabled = true; renderers.production.globalSamplerClassByName = "Hammersley"; renderers.production.globalSamplerQuality = 0.5; scanlinerender.antiAliasfilter = Area())
4: (renderers.production.globalSamplerEnabled = true; renderers.production.globalSamplerClassByName = "Hammersley"; renderers.production.globalSamplerQuality = 1.0; scanlinerender.antiAliasfilter = Catmull_Rom())
)
)
on btn_render pressed do
(
if chk_auto.checked == false then
(
undo On
(
qual()
bakeNorm()
)
)
else
(
undo On
(
qual()
unwrapNormAuto lowpoly
bakeNorm()
)
)
)
)
createDialog nm
)
barigazy · 2012-09-23
You should write a book if you start to explain the whole process. :)
By the way, great code
MKlejnowski · 2012-09-23
i wish i could take credit for it but I can't. I would like to dig a little deeper into it but for now i never had to have more than confirm buttons being pushed.
Goonda · 2012-09-24
Wow....Although I didn't know how but its working....Thanks a lot!!! I will try to understand the script...!!
MKlejnowski · 2012-09-25
Dialog monitor ops is just a feature in maxscript which allows you to interact with different dialogs that appear.
Here is how it works in your case....Correct me if i'm wrong anyone.
this line of code unregister any dialogMonitorOps with the id:#test. Just good practice to unregister before you register a new one.
dialogMonitorOps.unRegisterNotification id:#test
The function it self is the action that will happen when the monitor ops realizes that a dialog has popped up. The code
uiaccessoris used to to interact with the dialog. Since the confirm button is the default button when the dialog shows up i just used the
uiaccessor.pressdefaultbutton()function
fn checkDialog =
(
local hwnd = dialogMonitorOps.getWindowHandle()
if (hwnd == 0) then ( false )
else (
format "==================================================\n"
format "%\n" hwndText
local children = uiAccessor.getChildWindows hwnd
format "--------------------------------------------------\n"
for child in children do (
format "%\n" (uiAccessor.getWindowText child)
)
format "==================================================\n"
uiAccessor.pressDefaultButton()
true
)
)
From here on out you just turn on the dialog ops and make it so it does the work for you. You also register previous function to run if a dialog appears.
dialogMonitorOps.enabled = true
dialogMonitorOps.interactive = false
dialogMonitorOps.registerNotification checkDialog id:#test
At this point you run the script which usually stop because of some form of dialog. In your case it was the line below. I went ahead and commented out the quiet since you do want the dialog to appear.
local vfb = render rendertype:#bakeSelected outputwidth:size outputheight:size cancelled:&wascancelled --quiet:trueOnce thats done you just turn off the dialog ops and unregister your function again
dialogMonitorOps.enabled = false
dialogMonitorOps.unRegisterNotification id:#test
MKlejnowski · 2012-09-19
What max version are you running in? I just applied a bitmap on an obj in 2011. then moved the bitmap into a new folder and tried
render()which gave me the "continue" dialog. Then I tried
render quiet:truethe dialog did not appear. I noticed you spelled "quiet" incorrectly in your post which leads me to believe you have spelled it wrong in your code. It would still run and not throw up an error so check that first.
Goonda · 2012-09-21
Thanks for the reply MKlejnowski.....sorry I spelt it wrong here....but in the script it is correct.....the problem is when I am using my script....some missing texture message comes....if I press "continue"....the rest of the script is running fine.....same thing when I try to do with "quiet:true"....it dosent show any error....but stops the script there!!