Announcement

Collapse
No announcement yet.

Placing .vrmesh proxies using Grasshopper?

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

  • Placing .vrmesh proxies using Grasshopper?

    I am trying to do something sort of advanced, but it looks like it should be possible. I am trying to build a Grasshopper script that takes a bunch of geometries, turns them into .vrmesh files and then replaces the geometries that were used to create the .vrmesh files. So basically exactly what happens when you run "Export Proxy.." and leave the option "Replace Object with Proxy" on. I am doing this in bulk for many objects, so doing it by hand is not reasonable.

    The idea is that in the end this will be run in Rhino using Grasshopper Player.

    I have basically got everything running using the V-Ray exporter inside an Anemone loop. But the V-Ray Proxy Mesh component does not really do anything for me. I give it a grafted list of file names (the ones I created earlier) and a matching grafted list of planes for where to place them, but nothing happens. Nothing get's placed in the viewport and also in the Asset Editor no .vrmeshes show up. If I use the normal "Import Proxy or VRScene" functionality of V-Ray I can place the .vrmesh files no problem.

    Click image for larger version

Name:	Screenshot 2023-05-15 192010.png
Views:	192
Size:	342.1 KB
ID:	1180863

    What exactly is the V-Ray Proxy Mesh supposed to do? Shouldn't it import the proxy and place it? It's not doing that for me, even if I just place the component on it's own and give it one plane and one file path.

  • #2
    Is it possible that V-Ray Proxy Mesh is not the same as ImportVrayProxy? Now that I am reading over the very minimal documentation I can't see anywhere that it will actually import the proxy, but probably just loads the geometry in Grasshopper.

    I noticed there is a Rhino command called vrayProxyImport​, but it doesn't seem to have any options like a file path.

    So is there a way to use Python/RhinoScript/C# or Grasshopper to import and place proxies programmatically?

    I am using the script to generate something like 64 proxies at a time and would like to replace the original geometry with the proxy, just the same way it happens when you do it manually.

    How can I do that?

    Comment


    • #3
      Hi
      You're on the right track.

      The proxy import command need to be run in non-interactive mode.This way it will prompt for the filename and insertion point on the command line. If you want to script it, it should look like so:

      Code:
      RhinoApp.RunScript($"-_vrayProxyImport \"{filename}\" {x},{y},{z}", true);
      The grasshopper proxy component does not operate in Rhino. It outputs a VGeo, you plug that into a GH renderer component. Everything stays in GH. There is no connection whatsoever between that component and any actual geometry in Rhino. Apart from the preview bounding box. Mind that no V-Ray Grasshopper component is designed to be bakeable. The generated geometry is always render-time only.

      Comment


      • #4
        How do I use it? I am trying using a C# component in Grasshopper, but it's not really doing anything!?

        Like so:

        Click image for larger version

Name:	image.png
Views:	109
Size:	392.6 KB
ID:	1180929
        Attached Files

        Comment


        • #5
          Apparently I overestimated the C# version that GH is using. The interpolated strings are not a thing there, and you need to do it the old way

          Code:
          string command = string.Format("-_vrayProxyImport "{0}" {1},{2},{3} _Enter", filepath, position.X, position.Y, position.Z);
          Rhino.RhinoApp.RunScript(command, true);​​
          the "Enter" at the end stops the command, since it expects more coordinates for more instances
          Last edited by nikolay.bakalov; 16-05-2023, 04:30 AM.

          Comment


          • #6
            Okay, thank you. I am playing around with it a bit. You have to escape the quotation marks around {0} or it will throw an error (at least for me it did). For me its:

            Code:
                string command = string.Format("-_vrayProxyImport \"{0}\" {1},{2},{3} _Enter", filepath, position.X, position.Y, position.Z);
                Rhino.RhinoApp.RunScript(command, true);​
            But I just noticed a much bigger problem for my GH Player plugin: The V-Ray Exporter disables Auto Export on every launch. But I need Auto Export on for it to do it's thing inside the loop.

            Click image for larger version

Name:	Screenshot 2023-05-16 141342.png
Views:	114
Size:	37.7 KB
ID:	1180944

            If I enable it, save the file and reopen it, Auto Export is now disabled again. Whyyy. All these right-click options are already stupid and should be inputs. Imagine you had a function in an API, but there is a parameter that exists, but you can't set and have to somehow activate manually every time. You would question the sanity of whoever created that.

            There is a lengthy discussion around this topic here: https://discourse.mcneel.com/t/trigg...s-button/90478

            So I guess I will have to instead write the whole thing in Python or RhinoScript. Does the V-Ray Exporter also exist as a Python or Rhino command?

            Comment


            • #7
              The reason why it is disabled is because it is not option that serialized with the component. I can change that

              Comment


              • #8
                That would be amazing. Then I could set Auto-Export to On and use it in my GH Player file.

                Comment

                Working...
                X