Skip to content

Commit

Permalink
AttributeTweaksUI : Don't name plugs after attribute names
Browse files Browse the repository at this point in the history
The user can change the value of the `name` plug later, after which things would be out of sync.
  • Loading branch information
johnhaddon committed Jul 6, 2023
1 parent 6e389b5 commit 3a329c7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions python/GafferSceneUI/AttributeTweaksUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,20 @@ def __addFromPathsMenuDefinition( self, paths ) :
for path in paths :
attr = node["in"].fullAttributes( path ) if useFullAttr else node["in"].attributes( path )
attributes.update( attr )
existingTweaks = { tweak["name"].getValue() for tweak in node["tweaks"] }

attributes = collections.OrderedDict( sorted( attributes.items() ) )

for key, value in [ ( k, v ) for k, v in attributes.items() if k.replace( ':', '_' ) not in node["tweaks"] ] :
for key, value in attributes.items() :
result.append(
"/" + key,
{
"command" : functools.partial(
Gaffer.WeakMethod( self.__addTweak ),
key,
value
)
),
"active" : key not in existingTweaks
}
)

Expand All @@ -245,8 +247,7 @@ def __addTweak( self, name, plugTypeOrValue ) :
else :
plug = Gaffer.TweakPlug( name, plugTypeOrValue() )

if name :
plug.setName( name.replace( ':', '_' ) )
plug.setName( "tweak0" )

with Gaffer.UndoScope( self.getPlug().ancestor( Gaffer.ScriptNode ) ) :
self.getPlug().addChild( plug )

0 comments on commit 3a329c7

Please sign in to comment.