diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp index 60159586da..fd07ecfcf4 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeSelection.cpp @@ -595,8 +595,6 @@ void ProxyShape::makeUsdTransformsInternal( /// must always exist, and never get deleted. auto check = m_requiredPaths.find(prim.GetPath()); if (check == m_requiredPaths.end()) { - UsdPrim prim = *it; - MObject node; createMayaNode( prim, @@ -611,7 +609,7 @@ void ProxyShape::makeUsdTransformsInternal( TransformReference transformRef(node, reason); transformRef.checkIncRef(reason); - const SdfPath path { usdPrim.GetPath() }; + const SdfPath path { prim.GetPath() }; m_requiredPaths.emplace(path, transformRef); TF_DEBUG(ALUSDMAYA_SELECTION) @@ -698,8 +696,19 @@ void ProxyShape::removeUsdTransformChain( // The Xform of the shape may have already been deleted when the shape was deleted if (h.isAlive() && h.isValid()) { - modifier.reparentNode(object); - modifier.deleteNode(object); + // Note: For some reason if deleting Maya object with MDagModifier, + // the parents of the node will also be deleted. + // The usual trick: + // modifier.reparentNode(object); + // modifier.deleteNode(object); + // that re-parent the object before deleting does not work here, + // the workaround here is to delete the node with MGlobal instead. + if (MGlobal::deleteNode(object) != MStatus::kSuccess) { + MString err; + err.format( + "Failed to delete Maya node for prim path ^1s.", parentPrim.GetText()); + MGlobal::displayError(err); + } } } diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Scope.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Scope.cpp index 7e3fba27be..660abfa792 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Scope.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Scope.cpp @@ -174,7 +174,8 @@ MBoundingBox Scope::boundingBox() const MBoundingBox bbox = MPxTransform::boundingBox(); UsdPrim prim = transform()->prim(); - if (prim) { + // Calculate bbox only if there is a proxy shape connected + if (foundShape && prim) { // Get purpose draw states bool drawRenderPurpose = false; bool drawProxyPurpose = false;