Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] General Discussion => Topic started by: cecofuli on 2013-03-28, 16:16:59

Title: Help: little changes to this script: Add Color Correct map v1.0 on VRayMtl
Post by: cecofuli on 2013-03-28, 16:16:59
Hi all,
I've this little script.
It adds a Color Correct map to every shader or selected object, if these shaders are a VRay Mat
Can you help me to change this script for Corona?
Thanks :)

Code: [Select]
macroScript CC_All category:"VRay" tooltip:"Add CC Map to all VRay Materials" buttontext: "CC All"
(
--CC Map in diffuse slot of ALL VRay Materials where a bitmap is present
if queryBox "Add CC Map to ALL VRay Materials?" do
(
vrmArr = getClassInstances vrayMtl
for vrm in vrmArr do
(
if isKindOf vrm.texmap_diffuse Bitmaptexture then
(
cc = ColorCorrection map:(vrm.texmap_diffuse) lightnessMode:1
vrm.texmap_diffuse = cc
)
)
)
)

macroScript CC_Selected category:"VRay" tooltip:"Add CC Map to Selected" buttontext: "CC Selected"
(
--CC Map in diffuse slot of SELECTED objects
objs = getCurrentSelection()

for obj in objs do
(
vrmArr = getClassInstances vrayMtl target:obj

for vrm in vrmArr do
(
if isKindOf vrm.texmap_diffuse Bitmaptexture then
(
cc = ColorCorrection map:(vrm.texmap_diffuse) lightnessMode:1
vrm.texmap_diffuse = cc
)
)
)
)
Title: Re: Help: little changes to this script: Add Color Correct map v1.0 on VRayMtl
Post by: racoonart on 2013-03-28, 16:31:12
I didn't test it but this should work:

Formatting got a litte screwed, but i wanted to show the changes bold; Header for macroscripts etc still need to be changed ;)

Quote
macroScript CC_All category:"VRay" tooltip:"Add CC Map to all VRay Materials" buttontext: "CC All"
(
   --CC Map in diffuse slot of ALL VRay Materials where a bitmap is present
   if queryBox "Add CC Map to ALL VRay Materials?" do
   (
      vrmArr = getClassInstances CoronaMtl
      for vrm in vrmArr do
      (
         if isKindOf vrm.texmapDiffuse Bitmaptexture then
         (
            cc = ColorCorrection map:(vrm.texmapDiffuse) lightnessMode:1
            vrm.texmapDiffuse = cc
         )
      )
   )
)

macroScript CC_Selected category:"VRay" tooltip:"Add CC Map to Selected" buttontext: "CC Selected"
(
   --CC Map in diffuse slot of SELECTED objects
   objs = getCurrentSelection()
   
   for obj in objs do
   (
      vrmArr = getClassInstances CoronaMtl target:obj
      
      for vrm in vrmArr do
      (
         if isKindOf vrm.texmapDiffuse Bitmaptexture then
         (
            cc = ColorCorrection map:(vrm.texmapDiffuse) lightnessMode:1
            vrm.texmapDiffuse = cc
         )
      )
   )
)
Title: Re: Help: little changes to this script: Add Color Correct map v1.0 on VRayMtl
Post by: cecofuli on 2013-03-28, 18:22:40
Thank you =) =) The script is not mine. I'm not able to write two rows of code :(
Title: Re: Help: little changes to this script: Add Color Correct map v1.0 on VRayMtl
Post by: racoonart on 2013-03-28, 18:56:05
With "Header for macroscripts" i mean this:
Quote
macroScript CC_All category:"VRay" tooltip:"Add CC Map to all VRay Materials" buttontext: "CC All"

You may want to change it so something that does not override the original Scripts ;) like:

Quote
macroScript CC_All category:"Corona" tooltip:"Add CC Map to all Corona Materials" buttontext: "CC All"
...
macroScript CC_Selected category:"Corona" tooltip:"Add CC Map to Selected" buttontext: "CC Selected"