Code Monkey home page Code Monkey logo

usd-sketchup's Introduction

Universal Scene Description Exporter for SketchUp

This plug-in adds the ability to export Pixar's Universal Scene Description files from SketchUp Pro. It has been tested with SketchUp Pro 2016, 2017, 2018 and 2019.

It adds three options to the File->Export->3D Model menu:

  • Pixar USD binary File (*.usd)
  • Pixar USD ASCII File (*.usda)
  • Pixar USDZ File (*.usdz)

There are also options on the export panel to conditionally export normals, curves, edges, and lines, as well as the ability to organize the USD as a single file or as a set of files that reference each other.

The usdz files this exporter writes out takes care to write out in a way that is compatible with Apple's ARKit 2, which is more constrained than the general usdz specification, but that support can be toggled on or off in the Options... dialog.

The exporter also leverages the new UsdPreviewSurface to support texture export from SketchUp.

Getting the Prebuilt Plugin for macOS

We are providing a pre-built version of the plug-in here. After downloading, you'll want to copy it into the PlugIns directory inside the SketchUp Pro app bundle. You can do this from the Terminal by the following. Note you will need to type an admin password, as that directory is probably write-protected.

sudo cp -rf USDExporter.plugin /Applications/SketchUp\ 2018/SketchUp.app/Contents/PlugIns/

Once you have copied it there, you should see the 3 USD export options under the File->Export->3D Model menu.

This build has been (lightly) tested on SketchUp 2019 (Version 19.2.221) on macOS 10.14.6, and was built with Xcode 10.3 (10G8)

Getting Help

Need help understanding certain concepts in USD? See Getting Help with USD or visit the forum.

If you are experiencing undocumented problems with the software, please file a bug.

Supported Platforms

SketchUp Pro runs on macOS and Windows, but this plug-in is currently only supported on macOS.

This plug-in was developed on macOS but care has been taken to make sure that, as much as possible, it should be straightforward to port to Windows. Both SketchUp's SDK (developer account required) on Windows and macOS contain an example plug-in called skp_to_xml, which this plug-in took inspiration from, so if someone wants to port this to Windows they should just need to look in the SDK/samples/skp_to_xml/win/ and in the USD SketchUp Mac folder here and do the equivalent for Windows.

Dependencies

Name Version
macOS 10.13 or higher
SketchUp Pro 2016 or higher
Xcode 9 or higher
SketchUp SDK recent
USD 18.09 or higher

Getting and Building the Code

1. Install prerequisites (see Dependencies for required versions)

Note: to build this plug-in you will need a SketchUp Developer/Trimble account and an Apple Developer account.

The rest of these instructions assume you have a Mac with Xcode and SketchUp Pro installed.

2. Download the USD source code

You can download source code archives from GitHub or use git to clone the repository.

git clone https://github.com/PixarAnimationStudios/USD

3. Run the USD build script

MacOS:

In a terminal, run xcode-select to ensure command line developer tools are installed. Then run the script. We recommend building without Python, without imaging, and as a monolithic library that includes tbb in it. The included Xcode project assumes that it has been built that way and installed into /opt/local/USDForSketchUp.

python USD/build_scripts/build_usd.py --build-args TBB,extra_inc=big_iron.inc --no-python --no-imaging --no-usdview --build-monolithic /opt/local/USDForSketchUp

4. Download the SketchUp SDK

Once you login to the Trimble/SketchUp developer account (look in upper right corner of that linked page), download the SDK. Unzip and install this somewhere on your machine, for example, ~/SketchUpSDKs/SDK_Mac_2019-0-752_0

5. Download the USD SketchUp exporter plug-in source code

You can download source code archives from GitHub or use git to clone the repository.

git clone https://github.com/drwave/usd-sketchup

At the top level of the repository, make a link to the SketchUp SDK you installed. For example, if the SDK you downloaded was SDK_Mac_18-0-18665 and you put it in a subdirectory off your home directory called SketchUpSDKs, you would do:

cd usd-sketchup
ln -s ~/SketchUpSDKs/SDK_Mac_2019-0-752_0 SDK_Mac

6. Build the USD SketchUp exporter plugin

Launch Xcode on the project file. You may need to fix up various things in the Xcode file that are specific to your build if you have changed them (i.e. installed USD in a different location, have a different version of SketchUp installed, etc.).

You should create symlinks for SketchUp SDK (as SDK_Mac) and USD (as USD) in this folder.

For example:

ln -s /Users/<you>/SketchUpSDKs/SDK_Mac_2019-0-752_0 ./lib/SDK_Mac
ln -s /opt/local/USDForSketchUp ./lib/USD

The Xcode project assumes that you are building for SketchUp Pro 2019, and building the target will actually copy the resulting USDExporter.plugin into SketchUp Pro's app bundle in the PlugIns directory, i.e. /Applications/SketchUp\ 2019/SketchUp.app/Contents/PlugIns/.

Initially, that directory will probably not be writable on your machine, so you may need to make it writable:

sudo chmod a+w /Applications/SketchUp\ 2019/SketchUp.app/Contents/PlugIns/

Copying the plug-in to the directory makes it very easy to debug the plug-in, as you can launch SketchUp Pro from inside of Xcode, set breakpoints in your plug-in, etc. Very handy when doing development.

6. Build the USD SketchUp exporter command line app

Launch Xcode on the project file. You may need to fix up various things in the Xcode file that are specific to your build if you have changed them (i.e. installed USD in a different location, have a different version of SketchUp installed, etc.).

Contributing

If you'd like to contribute to this USD plug-in (and we appreciate the help!), please see the Contributing page in the documentation for more information.

usd-sketchup's People

Contributors

drwave avatar jchen9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usd-sketchup's Issues

texture export can sometime report the wrong file extension

When exporting this file, we see that it writes out a PNG into the Textures directory "B23A2.png", but in the USDA file we're writing out a reference to the texture, we're writing out "B23A2.BMP". I assume that's because it was originally a BMP file, but SketchUp has decided to change it to PNG (which is great, since USD doesn't generally support BMP), but wherever we're reading the texture name we need to make sure it's mapping to the file on disk.

FloorTile_NoComponent.zip
Archive.zip

Plugin isn't loaded in SketchUp 2019

Finally tried the plug-in with SketchUp 2019 (using the same plug-in that loads fine in 2018).

I get the error:

Cannot find plugin in /Applications/SketchUp 2019/SketchUp.app/Contents/PlugIns/USDExporter.plugin

Not sure where that error message is coming from. I'm not sure what changed for plugins for SketchUp 2019 from 2018.

There should be a way to map "real" materials to the simple materials in SketchUp

Upon export, it would be great if the exporter allowed a mapping of the simple material (i.e. just a texture map) that SketchUp has to some more complex material that was leveraging all the parameters of the UsdPreviewShader.

There are several ways this could be accomplished:

  • export the names of all the materials in the .skp file, and then import a mapping of those to values, perhaps encoded as a .json file.

Have a UI that presented the texture images on one side and a palette of discovered materials on the other side. Using drag and drop you could map one to the other.

Probably makes sense to start off with some .json based scheme and then perhaps do a UI later.

The big issue is what is that representation of rich materials look like? Is there any effort to generate these? Is this something Substance Designer could help with?

USDZ line entities not visible in AR Quicklook

After exporting various types of entities from SketchUp found that line entities are not visible in AR Quicklook for usdz, whereas for usd and usda line entities are visible in AR Quicklook.
Screenshot 2020-11-18 at 11 35 55 PM
Screenshot 2020-11-18 at 11 35 38 PM
Screenshot 2020-11-18 at 11 34 53 PM

there should be a command line app

Given this plug-in, it should be straightforward to build a simple command line app that takes a .skp file and generates a .usd[|a|z] file.

USDZ plugin for Apple Silicon

Would be great if plugin would be compiled for Apple Silicon. It doesn't work on Sketchup 2022 which is AS compatible, until you switch it back to x86 Rosetta mode.

some materials are not found

For some sketchup models, I'm currently not finding the texture material. This seems related to if the model is a component. Here are two files, one of which is a component, and we don't find the texture, but if we make the model not a component, we do find the texture.

FloorTile_NoComponent.zip
FloorTile.zip

Plug-In should remember checkboxes between launches

We should save all the various export flags we can check or set on the exporter between launches of SketchUp.

On the Mac, the standard practice is to use the defaults mechanism, but maybe we can write out a .usd-sketchup file or some such in the user's home directory...

Regardless, we should save the aspect ratio and boolean state of all the flags.

materials and display color don't play nice

Given a mesh that is broken up into multiple faces.

If you put solid colors as materials on all the faces, it gets exported correctly as display color.

If you have a textured material on any of the faces, the faces that have solid colors on them have undefined behavior - sometimes they have a colored variant of the texture materials, sometimes, they have no color at all.

I think the correct answer is to just stop using displayColor/Opacity and make materials for colored faces instead, but need to do some more research...

MaterialColorBug.zip

optimize single GeomSubset

Because USD's Hydra's StreamGL renderer does not currently support GeomSubset, you can trivially exported textured geometry from this exporter that current usdview w/Hydra doesn't render correctly (i.e. no texture). In many cases, there are single faces (with two sides) that are using GeomSubset, but it's really not a subset, it's the whole thing.

In that case, we should omit doing the material as a subset and just apply the material to the whole mesh.

No UI for toggling ARKit 2 compatibility

A .usdz file can have have arbitrary collection of USD files in it, but in order to currently be compatible with Apple's ARKit 2, we make a single binary USD file that specifically has a ".usdc" extension.

Internally, we have a flag that allows toggling this strict compatibility, which then uses a different code path.

Currently there is no user facing UI to allow this to be toggled.

unsupported path names

using this SketchUp model from 3Dwarehouse

clock

seems to display ok in xcode beta6, but crashes in IOS12 beta 12

clock

Does not have any errors when exporting to usdz from SketchUp. However, if I export as usda from SketchUp and use the xcrun usdz_converter to convert to usdz, I get the following complaint about path names.

iMac:COLLADA2GLTF ashleyjoyce$ xcrun usdz_converter clock.usda clock.usdz
usd_converter converting file: clock.usda
converted usdz file: clock.usdz
Coding Error: in _ValidateEditPrim at line 1157 of /Library/Caches/com.apple.xbs/Sources/ModelKit/ModelKit-1.94.23/ModelKit/extern/usd/pxr/usd/usd/stage.cpp -- Cannot create property spec at path </__Master_2/Materials/Material/Texture>; authoring to an instancing master is not allowed.
Runtime Error: in _SetValueImpl at line 1494 of /Library/Caches/com.apple.xbs/Sources/ModelKit/ModelKit-1.94.23/ModelKit/extern/usd/pxr/usd/usd/stage.cpp -- Cannot set attribute value.  Failed to create attribute spec </__Master_2/Materials/Material/Texture.inputs:file> in layer @/opt/COLLADA2GLTF/clock_$$usd_converter$$_.usdc@

should replace all calls to SU_CALL

with a more helpful macro including specific error msg. If we throw an exception in the importer, we should make sure to tell what went wrong. Ideally, this would be a user facing result with an alert.

summary display at export should be more useful

For complexity tracking purposes, it should also show:

  • how many materials were exported
  • how many geom subsets were created
  • how long it took

There may be other useful pieces of info as well.

Materials should be in their own layer

In order to correctly represent face color from SketchUp in USD, I really need to make a Material to do this. Best practice seems to indicate that I should have a shader graph at the top of the scene that can serve as a fallback to map displayColor to the color3f inputs:diffuseColor and float inputs:opacity to displayOpacity.

For debugging, and just general clarity, I should write these to their own layer.

Options panel should correctly show what can/can't be picked

For some choices of export, some options don't make sense. For example, if "Export as ARKit Compatible" is checked, then "Export to a Single File" should be checked and it should be greyed out, as it can't be unchecked.

Also, if there are no cameras (i.e. "Scenes" in SketchUp) the Aspect Ratio should be greyed out as should "Export Cameras"

Y-Up support

SketchUp is natively Z-up, and USD allows one to encode a scene either Y-Up (like, say Maya) or Z-Up (like SketchUp).

The way USD works is that only the orientation of the top level layer counts, so if one has an all Y-Up pipeline but wants to get some USD assets in from SketchUp, it would be useful if there was a toggle to allow the asset that gets generated to be Y-Up.

It's not clear what the right way to do this is, though. We could rotate the scene -90 in X and then tag it Y-Up, we could transform all the points, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.