USD File I/O Improvements in Rhino V9 WIP

Note : This guide requires the Rhino 9 WIP. This is a work in progress meaning that it is meant for testing and should not be used for project critical production work. The Rhino 9 WIP is available to anyone that owns Rhino 8.

USD files can now be used to encode information for the exchange of BIM information to common workflows. Geometry, Layers, Blocks, UserData and Object Properties will now be transmitted into USD data.

For developers, the RhinoUSD project is open source codebase written in C++ .

Rhino Objects to USD

Here are the changes to USD format and how Rhino objects are encoded into USD. Based on support for USD geometry in general, all geometry objects are exported as mesh objects.

  1. Additional Export Options on USD - Use this to configure output USD files.
  2. Included Userdata text on objects - Userdata can be used to add metadata to the prim objects in the USD file.
  3. Blocks exported - Block Instances are now exported in full. But also options with blocks can be saved.
  4. Exporting should be scriptable, i.e via aliases, etc
  5. Exporting should also be possible via Python/c# (see attached)

USD File Options

Here is the new USD Options dialog:

  • Default Layer - This is the name for the Root prim of the USD file that all other data fits under.
  • Model Name - This is an optional prim. This can be used to make composing multiple USD files easier.

Include User Strings from Rhino into USD

Userdata on objects within Rhino with the Key:Value pairs. This information is saved on the prims as CustomData in the USD. It is meant to be used for all sorts of metadata that can be explored in other USD viewing apps.

Block Export options

Blocks definitions and their instances are now exported with the USD.

Block Handling Options

  • Blocks as Separate files - This is the most efficient way to save a USD file. Each Block will create a separate USD file. These files will then reference each other. This can improve the performance of USD viewers.
  • Ignore - Ignore
  • Embedded - Block definitions are included within the USD file. This makes it easy to move the file around, but is less efficient for viewers.

Scripting Export to USD

USD export can be scripted in RhinoCommon in Python or C# using code similar to this sample:

using System;
using System.IO;

using Rhino;
using Rhino.FileIO;
using Rhino.Collections;

var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

var options = new FileWriteOptions()
                {
                    WriteSelectedObjectsOnly = true,
                    SuppressAllInput = true,
                    SuppressDialogBoxes = true,
                };

// Block Options
// SeparateFiles = 0
// Ignore = 1
// Embedded = 2

var dictionary = new ArchivableDictionary();
dictionary.Set("blocks", 2);
dictionary.Set("root-layer", "RootPrim");
dictionary.Set("model-name", "MyModel");
dictionary.Set("include-user-strings", false);

var doc = RhinoDoc.ActiveDoc;
doc.Export(Path.Combine(desktop, "usd.usdz"), dictionary);
5 Likes

I’ve tried to export 25 identical blocks to a *.usdz file and it failed until I added a mesh box next to the blocks. Unfortunately I only see one of the blocks and not all instances.

Also the blocks actually contain breps and I’m unsure if I need to mesh the geometry before exporting.

Another issue seems to be whether a block is embedded or linked.

25 identical blocks should create 25 instances, but only one extra external file.

USDZ format is a zipped format. I have not done this, but rename it .zip and see what is inside it.
USDA is an ascii text format
USDC is a binary format I believe.

Both USDA and USDC should have the external blocks showing up in the folder with the main USD.

Meshing should happen no matter if it is the block or not, but I will test that.

I opened the file in iRhino and all I see is a mesh box and one instance of my block.

This is my test file:

box and 25 blocks.3dm (222.4 KB)

And an export:

m6x50-cap.usdz (181.5 KB)

I see the issue with a pure block model. It does take an object in there.

I will get these on the list to fix.

1 Like

My goal is to export a couple thousand block instances scaled to different lengths and with a selection of colors…

image

At the moment each wire you can see is one mesh pipe. All meshes are disjoint.

1 Like

Those looks great. What a great test for this.

2 Likes

RH-88697 is fixed in Rhino WIP

Thanks for all the bug reports so far, keep 'em coming. If you have a sample file with something like that I’d love to stress test!

1 Like