Skip to content

Commit 126e1ea

Browse files
authored
Merge pull request #4074 from Autodesk/bailp/EMSUSD-2014/bad-object-message
EMSUSD-2014 report error for invalid include and exclude
2 parents bea834d + e605ef3 commit 126e1ea

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/host.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
from typing import Sequence
2+
from enum import Enum
23
from pxr import Usd
34

45

6+
class MessageType(Enum):
7+
'''
8+
Message type used to report messages in the DCC.
9+
'''
10+
INFO = 1
11+
WARNING = 2
12+
ERROR = 3
13+
14+
515
class Host(object):
616
_instance = None
717

@@ -47,6 +57,13 @@ def pick(self, stage: Usd.Stage, *, dialogTitle: str = "") -> Sequence[Usd.Prim]
4757
'''
4858
return None
4959

60+
def reportMessage(self, message: str, msgType: MessageType=MessageType.ERROR):
61+
'''
62+
Report an error message using the DCC-specific logging system.
63+
By default, simply print the error with an "Error: " prefix.
64+
'''
65+
print('%s: %s', (msgType, message))
66+
5067
def createCollectionData(self, prim: Usd.Prim, collection: Usd.CollectionAPI):
5168
'''
5269
Create the data to hold a USD collection.

lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/data/stringListData.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ def _isValidString(self, s) -> AnyStr:
4747

4848
def addMultiLineStrings(self, multiLineText):
4949
items = []
50+
reportedError = False
5051
for text in multiLineText.split("\n"):
5152
text = self._isValidString(text)
52-
if text is None:
53+
if not text:
54+
if not reportedError:
55+
reportedError = True
56+
from ..common.host import Host
57+
Host.instance().reportMessage("Only objects in the same stage as the collection can be added.")
5358
continue
5459
items.append(text)
5560

lib/mayaUsd/resources/ae/usdschemabase/collectionMayaHost.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from usd_shared_components.common.host import Host
2+
from usd_shared_components.common.host import Host, MessageType
33
from usd_shared_components.common.theme import Theme
44
from usd_shared_components.usdData.usdCollectionData import UsdCollectionData
55
from usd_shared_components.usdData.usdCollectionStringListData import CollectionStringListData
@@ -239,7 +239,7 @@ def registerCommands(pluginName):
239239
try:
240240
plugin.registerCommand(cls.commandName, cls.creator, cls.createSyntax)
241241
except Exception as ex:
242-
print(ex)
242+
MGlobal.displayError(ex)
243243

244244
def deregisterCommands(pluginName):
245245
'''
@@ -256,7 +256,7 @@ def deregisterCommands(pluginName):
256256
try:
257257
plugin.deregisterCommand(cls.commandName)
258258
except Exception as ex:
259-
print(ex)
259+
MGlobal.displayError(ex)
260260

261261

262262
class MayaCollectionData(UsdCollectionData):
@@ -334,6 +334,14 @@ def canDrop(self) -> bool:
334334
def pick(self, stage: Usd.Stage, *, dialogTitle: str = "") -> Sequence[Usd.Prim]:
335335
return [] # nothing to do yet
336336

337+
def reportMessage(self, message: str, msgType: MessageType=MessageType.ERROR):
338+
if msgType == MessageType.INFO:
339+
MGlobal.displayInfo(message)
340+
elif msgType == MessageType.WARNING:
341+
MGlobal.displayWarning(message)
342+
elif msgType == MessageType.ERROR:
343+
MGlobal.displayError(message)
344+
337345
def createCollectionData(self, prim: Usd.Prim, collection: Usd.CollectionAPI):
338346
return MayaCollectionData(prim, collection)
339347

0 commit comments

Comments
 (0)