Rhino WIP Feature: USD File I/O Improvements

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

Latest 9 WIP installed this morning.

I exported an art piece containing 296 blocks and 24 polysurfaces.

The 296 blocks are 24 blocks with multiple instances.

The *.usdz file contains just one block when the polysurfaces are not part of the export and just one instance of each block when the polysurfaces are also exported. Colors work nicely.

I chose the embedded option.

A small detail: The export options have a default name for Model Name set to ‘test_01’
I would much prefer ‘test-01’ since we with most files the underscore is used to separate different parts of a structured filename. A concatenated file name could be something like this:

pm_spoon_3-5_16-tiles_3mf-inserted-linked-blocks_test-01.extension

Here is a simple file with three block instances and one polysurface.

test-usdz-9.3dm (364.0 KB)

test-usdz-9.usdz (52.2 KB)

The export contains just one block instance and a meshed box.

I tried to export the same geometry as *.usda and then zip it and change the extension to .usdz but wasn’t successful yet.

The filesize looks right in the *.usda

1 Like

Here’s my attempt to create a better example file:

test-usdz.gh (48.1 KB)
test-usdz-9.3dm (342.2 KB)

The goal is to have a lightweight *.usdz file with just two meshes instead of hundreds of meshes.

The next step would be to have more individual colors.

test-usdz-9.3dm (342.2 KB)
test-usdz.gh (48.1 KB)

Exporting the geometry in my file runs ‘Meshing…’ 699 times, 233 times for each of the three blocks. The resulting file however only contains one pipe and one sphere. I’m using either this viewer or iRhino to view *.usdz files.

I want the file to contain all blocks so I choose Embedded:

test-usdz-9.usdz (12.6 KB)

The filesize is larger when exporting *.usda

image

Exporting as *.usdz, changing the extension to *.zip and unpacking the file shows a *.usdc file which I’m not sure if it makes sense. Shouldn’t the extracted *.usd? file be human readable?

File Identification for USD is:

USDA files are plain ascii and will tend to be larger. But, are human readable.

USDC are binary “crate” files. For faster access and will tend to be smaller.

USDZ is a container for the format in a ZIP structure, used by Apple for 3D and AR applications[3]. There is some streaming and display efficiency with having referenced external blocks with online viewers. So USDz can do this but keep the package as one file.

USD can technically be either ASCII or binary format.

Thanks for the information @scottd

I see that, however also iRhino has its issues. I thought human readable would make sense to verify the content.