Announcement

Collapse
No announcement yet.

Maxscript to disable/enable "Get Resolution from Max"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maxscript to disable/enable "Get Resolution from Max"

    Is there a way to enable/disable Get Resolution from Max with Maxscript? I'm trying to create a pre-render and post-render script that takes the resolution from Max, puts in the width and height from Vray and then takes the simplest form of the resolution and puts that in the resolution of Max. Then after the render puts everything back to its original state. The only thing I can't seem to find is the code for enabling or disabling get resolution from max.

    As to why I'm trying this: https://forums.chaos.com/forum/v-ray...me-buffer-size
    A.

    ---------------------
    www.digitaltwins.be

  • #2
    The property is called
    "output_getsetsfrommax"
    Lele
    Trouble Stirrer in RnD @ Chaos
    ----------------------
    emanuele.lecchi@chaos.com

    Disclaimer:
    The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

    Comment


    • #3
      Originally posted by ^Lele^ View Post
      The property is called
      "output_getsetsfrommax"
      Thanks Lele, is there a list somewhere or documentation, because I couldn't find it in the chaos docs.

      I found the vr properties command but maybe there's some more documentation on all the properties?

      EDIT:

      I just tried vr.output_getsetsfrommax, it returns as false, whether it's turned on or not. If I do vr.output_getsetsfrommax = true or false it doesn't seem to change in the UI.

      I'm just learning to script so forgive me if I'm asking stupid questions.
      Last edited by Vizioen; 17-05-2023, 02:43 AM.
      A.

      ---------------------
      www.digitaltwins.be

      Comment


      • #4
        Originally posted by Vizioen View Post

        Thanks Lele, is there a list somewhere or documentation, because I couldn't find it in the chaos docs.
        The only way to figure them out is via the show() command, f.e.
        Code:
        show renderers.current

        I just tried vr.output_getsetsfrommax, it returns as false, whether it's turned on or not. If I do vr.output_getsetsfrommax = true or false it doesn't seem to change in the UI.
        Eheh, you need to call "renderSceneDialog.commit()" to see the changes.
        https://help.autodesk.com/view/MAXDE...7-BB94F00AC841
        Lele
        Trouble Stirrer in RnD @ Chaos
        ----------------------
        emanuele.lecchi@chaos.com

        Disclaimer:
        The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

        Comment


        • #5
          Originally posted by ^Lele^ View Post
          The only way to figure them out is via the show() command, f.e.
          Code:
          show renderers.current


          Eheh, you need to call "renderSceneDialog.commit()" to see the changes.
          https://help.autodesk.com/view/MAXDE...7-BB94F00AC841
          Thanks.

          When I try this:

          vr.output_getsetsfrommax = true
          renderSceneDialog.commit()

          The Render Settings windows flashes but there are no changes, neither true nor false changes the UI.​

          I even tried renderSceneDialog.update()

          A.

          ---------------------
          www.digitaltwins.be

          Comment


          • #6
            It works fine for me, even without committing...

            Click image for larger version

Name:	3dsmax_OE8DKegK5a.gif
Views:	209
Size:	50.4 KB
ID:	1181042​
            Lele
            Trouble Stirrer in RnD @ Chaos
            ----------------------
            emanuele.lecchi@chaos.com

            Disclaimer:
            The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

            Comment


            • #7
              Indeed it works with renderers.current. but not with vr.

              Almost there, so far I have this:

              Code:
              -- Store the original values
              originalWidth = renderWidth
              originalHeight = renderHeight
              
              -- Set VRay width and height
              renderers.current.output_width = originalWidth
              renderers.current.output_height = originalHeight
              
              -- Calculate the simplest form of the original output size
              fn simplifyFraction num den = (
                  common = gcd num den
                  #(num/common, den/common)
              )
              
              simplifiedValues = simplifyFraction originalWidth originalHeight
              
              -- Set new resolution in 3ds Max
              renderWidth = simplifiedValues[1]
              renderHeight = simplifiedValues[2]
              
              --Disable get resolution from Max
              renderers.current.output_getsetsfrommax = false​
              But there must be something wrong with my logic, because it worked once, and then it stopped working properly, it started to set the simplest form values in the vray output settings not in 3ds Max.
              ​
              A.

              ---------------------
              www.digitaltwins.be

              Comment


              • #8
                I've got it working, although I'm not sure if what I'm doing is correct in terms of coding, but adding renderscenedialog.close() in the beginning works.

                Now to create a post render script that puts everything back in its place.
                Last edited by Vizioen; 17-05-2023, 03:45 AM.
                A.

                ---------------------
                www.digitaltwins.be

                Comment


                • #9
                  So it only works when using it manually, when set as a pre-render script, it doesn't seem to be doing anything. Am I missing something?
                  A.

                  ---------------------
                  www.digitaltwins.be

                  Comment


                  • #10
                    Anyone with better scripting capabilities that knows what I'm doing wrong? I've already posted on the maxscript FB group but no response either
                    A.

                    ---------------------
                    www.digitaltwins.be

                    Comment


                    • #11
                      Try turning off the maxscript safety bits.
                      If that fails, try and set the scope to a local one (add a pair of brackets enclosing the script.), so you'll know which variable has or has not been initialised right at the beginning of the script.
                      If that fails as well, kindly send me the latest copy of the script and i'll take a look.
                      Lele
                      Trouble Stirrer in RnD @ Chaos
                      ----------------------
                      emanuele.lecchi@chaos.com

                      Disclaimer:
                      The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                      Comment


                      • #12
                        Awesome I got it to work!!! Thank you Lele, appreciate it.
                        A.

                        ---------------------
                        www.digitaltwins.be

                        Comment


                        • #13
                          Originally posted by Vizioen View Post
                          Awesome I got it to work!!! Thank you Lele, appreciate it.
                          And you're not telling us how? How cruel!
                          Lele
                          Trouble Stirrer in RnD @ Chaos
                          ----------------------
                          emanuele.lecchi@chaos.com

                          Disclaimer:
                          The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                          Comment


                          • #14
                            Haha, that's the thing about scripting, especially when you don't know half of what you're doing, but I had some help of ChatGPT to rewrite some things and now it seems to work. I think something went wrong initially with calculating the greatest common divisor, although it worked at some point until it didn't.

                            Granted I'm not sure if it's the most optimal way of doing this,...probably not.

                            In any case if anyone might benefit from having these scripts, they are attached. Just put them in the Pre and Post render scripts in the Render Setup window. Not sure how much RAM this might save on bigger resolutions with multiple render elements, but every bit counts I guess .
                            Attached Files
                            A.

                            ---------------------
                            www.digitaltwins.be

                            Comment

                            Working...
                            X