diff --git a/source/blender/io/usd/intern/usd_writer_abstract.cc b/source/blender/io/usd/intern/usd_writer_abstract.cc index 4a443bbac64..5d1939c861f 100644 --- a/source/blender/io/usd/intern/usd_writer_abstract.cc +++ b/source/blender/io/usd/intern/usd_writer_abstract.cc @@ -261,7 +261,17 @@ bool USDAbstractWriter::mark_as_instance(const HierarchyContext &context, const return false; } - pxr::SdfPath ref_path(context.original_export_path); + BLI_assert(!context.original_export_path.empty()); + BLI_assert(context.original_export_path.front() == '/'); + + std::string ref_path_str(usd_export_context_.export_params.root_prim_path); + ref_path_str += context.original_export_path; + + pxr::SdfPath ref_path(ref_path_str); + + /* To avoid USD errors, make sure the referenced path exists. */ + usd_export_context_.stage->DefinePrim(ref_path); + if (!prim.GetReferences().AddInternalReference(ref_path)) { /* See this URL for a description for why referencing may fail" * https://graphics.pixar.com/usd/docs/api/class_usd_references.html#Usd_Failing_References