Skip to content

Commit 3582375

Browse files
committed
Merge pull request #276 from davidsminor/sceneShapeComponentNames
Scene shape component names
2 parents b8bcf5e + 696d909 commit 3582375

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

python/IECoreMaya/FnSceneShape.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,18 @@ def selectComponentNames( self, componentNames ) :
132132
componentNames = set( componentNames )
133133

134134
fullPathName = self.fullPathName()
135-
allnames = self.componentNames()
135+
allNames = self.componentNames()
136+
toSelect = []
136137
for i, name in enumerate( allNames ):
137138
if name in componentNames:
138139
toSelect.append( fullPathName + ".f[" + str( i ) + "]" )
139140

140141
maya.cmds.select( clear=True )
141142
maya.cmds.selectMode( component=True )
142143
maya.cmds.hilite( fullPathName )
143-
for s in toSelect :
144-
maya.cmds.select( s, add=True )
144+
if toSelect:
145+
maya.cmds.select( toSelect, r=True )
146+
145147

146148
## Returns the full path name to this node.
147149
def fullPathName( self ) :
@@ -157,7 +159,7 @@ def fullPathName( self ) :
157159
def sceneInterface( self ) :
158160

159161
return _IECoreMaya._sceneShapeSceneInterface( self )
160-
162+
161163
def componentNames( self ) :
162164

163165
return _IECoreMaya._sceneShapeComponentNames( self )

src/IECoreMaya/SceneShapeInterface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,11 +1384,15 @@ int SceneShapeInterface::selectionIndex( const IECore::InternedString &name )
13841384

13851385
IECore::InternedString SceneShapeInterface::selectionName( int index )
13861386
{
1387+
// make sure the gl scene's been built, as this keeps m_indexToNameMap up to date
1388+
const_cast<SceneShapeInterface*>( this )->glScene();
13871389
return m_indexToNameMap[index];
13881390
}
13891391

13901392
const std::vector< InternedString > & SceneShapeInterface::componentNames() const
13911393
{
1394+
// make sure the gl scene's been built, as this keeps m_indexToNameMap up to date
1395+
const_cast<SceneShapeInterface*>( this )->glScene();
13921396
return m_indexToNameMap;
13931397
}
13941398

test/IECoreMaya/FnSceneShapeTest.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,21 @@ def testConvertAllToGeometry( self ):
195195

196196
self.assertEqual( maya.cmds.getAttr( "|test|sceneShape_1|sceneShape_SceneShape1.queryPaths[1]" ), "/" )
197197
self.assertTrue( maya.cmds.isConnected( "|test|sceneShape_1|sceneShape_SceneShape1.outObjects[1]", "|test|sceneShape_1|sceneShape_Shape1.inMesh" ) )
198-
199198

199+
def testComponentNames( self ):
200+
201+
maya.cmds.file( new=True, f=True )
202+
fn = IECoreMaya.FnSceneShape.create( "test" )
203+
maya.cmds.setAttr( fn.fullPathName()+'.file', FnSceneShapeTest.__testFile,type='string' )
204+
maya.cmds.setAttr( fn.fullPathName()+".drawGeometry", 0 )
205+
self.assertEqual( fn.componentNames(), [] )
206+
207+
maya.cmds.setAttr( fn.fullPathName()+".drawGeometry", 1 )
208+
self.assertEqual( fn.componentNames(), ['/', '/1', '/1/child', '/1/child/3'] )
209+
210+
fn.selectComponentNames( ['/', '/1', '/1/child/3'] )
211+
self.assertEqual( fn.selectedComponentNames(), set( ['/', '/1', '/1/child/3'] ) )
212+
200213
def tearDown( self ) :
201214

202215
if os.path.exists( FnSceneShapeTest.__testFile ) :

0 commit comments

Comments
 (0)