Article about Installing USD on macOS (Mojave) and how to convert between different formats. It also shows how to setup Automator tasks for this processes.

This article is a detailed tutorial how to install USD on macOS (Mojave) and how to use its tools to convert 3D models between different formats. The tutorial includes detailed information about how to setup macOS Automator tasks to automate this processes and i.e. add them to the Finder context menu.

Homebrew install:

You need homebrew installed on macOS to continue with this tutorial. Execute the following command in a terminal to install homebrew on your macOS system:

  • /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

USD install:

Links:

 

USD Ressources

  1. Pixar’s open source github project on USD files
  2. Universal Scene Description Project
  3. USDZ File Format Specification

USD Format

Install Pixar USD on macOS X

 

############################################################
# USD

def InstallUSD(context, force, buildArgs):
    with CurrentWorkingDirectory(context.usdSrcDir):
        extraArgs = []

        if context.buildPython:
            extraArgs.append('-DPXR_ENABLE_PYTHON_SUPPORT=ON')
            if MacOS():
              import distutils.sysconfig
              pyLibPath = distutils.sysconfig.get_config_var('LIBDIR')
              pyIncPath = distutils.sysconfig.get_config_var('INCLUDEPY')
              extraArgs.append('-DPYTHON_LIBRARY=' + pyLibPath + '/libpython2.7.dylib')
              extraArgs.append('-DPYTHON_INCLUDE_DIR=' + pyIncPath)
        else:
            extraArgs.append('-DPXR_ENABLE_PYTHON_SUPPORT=OFF')



Converting between .usda and .usdc Files

We'll start with a simple .usda file, Sphere.usda in the USD/extras/usd/tutorials/convertingLayerFormats folder. This is a text format file, so it can be examined in any text editor or via usdcat.

$ usdcat Sphere.usda

#usda 1.0
def Sphere "sphere"
{
}

To convert this file to a binary format file, we can simply specify an output filename with the .usdc extension:

$ usdcat -o NewSphere.usdc Sphere.usda

This will produce a binary format file named Sphere.usdc in your current directory that contains the same contents as Sphere.usd, which we can verify using the usddiff tool:

$ usddiff Sphere.usda NewSphere.usdc

Converting from a binary format file to a text format file and verifying the contents match can be done in the same way:

$ usdcat -o NewSphere.usda NewSphere.usdc
$ usddiff NewSphere.usdc NewSphere.usda

Automator - Finder context menu entry - usdcat

#! /bin/bash

#Load Environment
source ~/.bash_profile

# Enter the first file's directory
current_path=$(dirname "$1")
cd "$current_path"

# For every file, unrar it to the current directory
for a in "${@##*/}"
do
	extension="${a##*.}"
	filename="${a%.*}"
	if [ "$extension" = "usda" ]
	then
		usdcat -o "$filename.usdc" $a
	else
		usdcat -o "$filename.usda" $a
	fi
done

# Exit 0 so annoying errors don't popup 
exit 0



USD Service Tools / Workflows for macOS X

Here are some Services / workflows for macOS Finder which allow direct access to USD from within Finder