Skip to content

Commit

Permalink
EMSUSD-993: When opening a file dependency in the AE, the dialog does…
Browse files Browse the repository at this point in the history
…n't open to the location of the file

* If we can resolve path to absolute, open the file dialog on that path.
* Fix spelling mistakes
  • Loading branch information
seando-adsk committed Apr 11, 2024
1 parent 3110b6a commit e5d1815
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
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
*/
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

0 comments on commit e5d1815

Please sign in to comment.