Skip to content

Commit

Permalink
fix GrillAttributeClearMenuItem for USD-21.11
Browse files Browse the repository at this point in the history
Signed-off-by: Christian López Barrón <[email protected]>
  • Loading branch information
chrizzFTD committed Dec 14, 2024
1 parent 98e396d commit eca9738
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion grill/views/usdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,17 @@ def RunCommand(self):

def IsEnabled(self):
# Usd.Attribute.Clear operates only on specs with an existing authored default value at the current edit target
try:
# USD>=24.11
spec_getter = Usd.EditTarget.GetAttributeSpecForScenePath
except AttributeError:
# USD<24.11
# Usd.EditTarget.GetSpecForScenePath did not work on earlier usd versions. It was fixed in 24.11.
def spec_getter(edit_target, path):
return edit_target.GetLayer().GetAttributeAtPath(edit_target.MapToSpecPath(path))

return super().IsEnabled() and any(
(spec := attr.GetStage().GetEditTarget().GetAttributeSpecForScenePath(attr.GetPath())) and spec.default
(spec := spec_getter(attr.GetStage().GetEditTarget(), attr.GetPath())) and spec.default
for attr in self._attributes
)

Expand Down

0 comments on commit eca9738

Please sign in to comment.