Itoo Software Forum

Author Topic: Script request: Material Optimizer related  (Read 675 times)

Haider of Sweden

  • Newbie
  • *
  • Posts: 41
    • Portfolio
Script request: Material Optimizer related
« on: January 03, 2017, 12:34:27 PM »
I would like to be able to open the Material Optimizer without going through a forest object.

Also, I would like to ask for a code that changes the RGB Level on selected material only, preferrably a tiny GUI where you set the value and then SET.
//Haider

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3315
    • iToo Software
Re: Script request: Material Optimizer related
« Reply #1 on: January 04, 2017, 09:25:10 AM »
Hi, thanks for your suggestion. Are you interested on any special feature, to use Material Optimizer with non-Forest objects ?
I guess there are some third-party tools with similar features, which can be used with any object.

By the way, Optimizer can be opened from Utilities->Forest Tools, for applyng it to all selected Forest objects.
Carlos Quintero
iToo Software

Haider of Sweden

  • Newbie
  • *
  • Posts: 41
    • Portfolio
Re: Script request: Material Optimizer related
« Reply #2 on: January 04, 2017, 12:58:06 PM »
Thank you Carlos for pointing out I could find the Forest Tools under Utilities.

Let me explain the reason why I need it on a non-forest object.
If I import multiple trees, FP bundles all the materials into one large single Multi Sub Object material.

When I run Optimizer and set an RGB value, it does it on all materials.
I encountered a special case where I needed different values on different on different materials.

Either one could have the option Apply to Selected Forest Object or Apply to Sub Geometry, or, your tool could work on non-forest objects.

Just as a parenthesis, I managed to open the Material Optimizer in a quick-and-dirty way.
Quote
macroScript OpenMaterialOptimizer
 category:"Haider"
 buttontext:"Mat Optimize"
 tooltip:"Open the Forest Tools Material Optimizer Floater with one click!"
 icon:#("Haider",7)
 (
    fn openOptimize =
    (
      WM_SETREDRAW=0xB
      commandHWND = windows.getChildHWND #max "Command Panel"      
      windows.sendmessage commandHWND[1]  WM_SETREDRAW 0 0
       local result = false --flag for success/failure
       local oldPannel = getCommandPanelTaskMode() --remember the old command panel tab
       UtilityPanel.OpenUtility Forest_Tools --open Utility tab and enable Forest Tools
       local theForestToolUtil = windows.getChildHWND #max "Forest Tools" --grab the Forest Tools's rollout handle
       if theForestToolUtil.count > 0 do --if it was found,
       (
          local theButton = windows.getChildHWND theForestToolUtil[7] "Optimize" --get the Optimize  button's handle
          print theButton
         if theButton.count > 0 do --if this succeeded too, then send messages to click it
          (
             Windows.sendMessage theButton[1] 0x201 0 0 --Left Mouse Button Down
             Windows.sendMessage theButton[1] 0x202 0 0 --Left Mouse Button Up
             result = true --raise the flag for success
          )
       )
       setCommandPanelTaskMode oldPannel --switch back to the previous command panel tab
      windows.sendmessage commandHWND[1]  WM_SETREDRAW 1 0
       result --return result
    )
 
    openOptimize()
 )
//Haider

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3315
    • iToo Software
Re: Script request: Material Optimizer related
« Reply #3 on: January 05, 2017, 09:38:40 AM »
Thanks for the explanation. But sincerely, your suggestion is too specific to be proposed for a future improvement. Actually we have many suggestions in the wishlist, and we must prioritize them.

If that helps, i would you send you the source code of the Material Optimizer. This is the only part of Forest written in Maxscrtipt, so hopefully you would adapt it to your needs.
Carlos Quintero
iToo Software

Haider of Sweden

  • Newbie
  • *
  • Posts: 41
    • Portfolio
Re: Script request: Material Optimizer related
« Reply #4 on: January 05, 2017, 09:42:46 AM »
Yes, please Carlos, do send me the script.
//Haider

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3315
    • iToo Software
Re: Script request: Material Optimizer related
« Reply #5 on: January 05, 2017, 03:56:16 PM »
Just sent.
Carlos Quintero
iToo Software

Kerezsi

  • Newbie
  • *
  • Posts: 5
Re: Script request: Material Optimizer related
« Reply #6 on: January 12, 2017, 05:46:20 PM »
Dear Carlos,

could you please send the script source for me, too?

I'd like to extend it with more options.

Laszlo

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3315
    • iToo Software
Re: Script request: Material Optimizer related
« Reply #7 on: January 13, 2017, 08:38:16 AM »
Sure. Sent by email.
Carlos Quintero
iToo Software