Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-993: When opening a file dependency in the AE, the dialog doesn't open to that path #3709

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/mayaUsd/resources/ae/usdschemabase/custom_image_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

import ufe

import os
from pxr import Sdf

try:
from PySide2 import QtCore
except:
Expand Down Expand Up @@ -132,8 +135,19 @@ def filenameBrowser(self, callback):

ImageCustomControl.fixFileDialogSplitters()

# Determine if we can get an absolute path from the attribute value.
# If we can then try and find the starting directory from that path.
startDir = None
usdAttr = self.prim.GetAttribute(self.attrName)
usdValue = usdAttr.Get()
if isinstance(usdValue, Sdf.AssetPath):
resolvedPath = usdValue.resolvedPath
if os.path.exists(resolvedPath):
# Use forward slashes in path to avoid any problems. Maya accepts them all platforms.
startDir = os.path.abspath(os.path.dirname(resolvedPath)).replace(os.sep, '/')

dialogArgs = {
'startDir' : mel.eval("""setWorkingDirectory("%s", "image", "sourceImages")""" % workspace),
'startDir' : startDir if startDir else mel.eval("""setWorkingDirectory("%s", "image", "sourceImages")""" % workspace),
'filter' : mel.eval("buildImageFileFilterList()"),
'caption' : getMayaUsdLibString('kOpenImage'),
'createCallback' : "mayaUsd_ImageFileRelative_UICreate",
Expand Down
14 changes: 7 additions & 7 deletions lib/mayaUsd/utils/utilFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ std::string getNumberSuffix(const std::string& text);
MAYAUSD_CORE_PUBLIC
std::string increaseNumberSuffix(const std::string& text);

/*! \brief returns the aboluste path relative to the maya file
/*! \brief returns the absolute path relative to the Maya file
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial - fixed a few spelling mistakes.

*/
MAYAUSD_CORE_PUBLIC
std::string resolveRelativePathWithinMayaContext(
Expand All @@ -273,10 +273,10 @@ bool pathAppendPath(std::string& a, const std::string& b);
/**
* Appends `b` to the path `a` and returns a path (by appending two input paths).
*
* @param a A string that respresents the first path
* @param b A string that respresents the second path
* @param a A string that represents the first path
* @param b A string that represents the second path
*
* @return the two paths joined by a seperator
* @return the two paths joined by a separator
*/
MAYAUSD_CORE_PUBLIC
std::string appendPaths(const std::string& a, const std::string& b);
Expand Down Expand Up @@ -308,17 +308,17 @@ void pathRemoveExtension(std::string& filePath);
MAYAUSD_CORE_PUBLIC
std::string pathFindExtension(std::string& filePath);

// Backup a file and restore it if not commited.
// Backup a file and restore it if not committed.
class FileBackup
{
public:
FileBackup(const std::string& filename);
~FileBackup();

// Once commited, the backup will not be put back into the original file.
// Once committed, the backup will not be put back into the original file.
void commit();

// Force restoration of the original file if successfully backed-up, even if commited.
// Force restoration of the original file if successfully backed-up, even if committed.
void restore();

// Return the backup file name.
Expand Down