@@ -202,6 +202,57 @@ def __queryIndexForPath( self, path ):
202
202
203
203
maya .cmds .setAttr ( node + ".queryPaths[" + str (index )+ "]" , path , type = "string" )
204
204
return index
205
+
206
+ ## create the given child for the scene shape
207
+ # Returns a the function set for the child scene shape.
208
+ def createChild ( self , childName , sceneFile , sceneRoot , drawGeo = False , drawChildBounds = False , drawRootBound = True , drawTagsFilter = "" ) :
209
+
210
+ node = self .fullPathName ()
211
+ transform = maya .cmds .listRelatives ( node , parent = True , f = True )[0 ]
212
+
213
+ if maya .cmds .objExists ( transform + "|" + childName ):
214
+ shape = maya .cmds .listRelatives ( transform + "|" + childName , f = True , type = "ieSceneShape" )
215
+ if shape :
216
+ fnChild = IECoreMaya .FnSceneShape ( shape [0 ] )
217
+ else :
218
+ fnChild = IECoreMaya .FnSceneShape .createShape ( transform + "|" + childName )
219
+ else :
220
+ fnChild = IECoreMaya .FnSceneShape .create ( childName , transformParent = transform )
221
+
222
+ childNode = fnChild .fullPathName ()
223
+ childTransform = maya .cmds .listRelatives ( childNode , parent = True , f = True )[0 ]
224
+ maya .cmds .setAttr ( childNode + ".file" , sceneFile , type = "string" )
225
+ sceneRootName = "/" + childName if sceneRoot == "/" else sceneRoot + "/" + childName
226
+ maya .cmds .setAttr ( childNode + ".root" , sceneRootName , type = "string" )
227
+
228
+ index = self .__queryIndexForPath ( "/" + childName )
229
+ outTransform = node + ".outTransform[" + str (index )+ "]"
230
+ if not maya .cmds .isConnected ( outTransform + ".outTranslate" , childTransform + ".translate" ):
231
+ maya .cmds .connectAttr ( outTransform + ".outTranslate" , childTransform + ".translate" , f = True )
232
+ if not maya .cmds .isConnected ( outTransform + ".outRotate" , childTransform + ".rotate" ):
233
+ maya .cmds .connectAttr ( outTransform + ".outRotate" , childTransform + ".rotate" , f = True )
234
+ if not maya .cmds .isConnected ( outTransform + ".outScale" , childTransform + ".scale" ):
235
+ maya .cmds .connectAttr ( outTransform + ".outScale" , childTransform + ".scale" , f = True )
236
+
237
+ maya .cmds .setAttr ( childNode + ".drawGeometry" , drawGeo )
238
+ maya .cmds .setAttr ( childNode + ".drawChildBounds" , drawChildBounds )
239
+ maya .cmds .setAttr ( childNode + ".drawRootBound" , drawRootBound )
240
+
241
+ if drawTagsFilter :
242
+ parentTags = drawTagsFilter .split ()
243
+ childTags = fnChild .sceneInterface ().readTags ()
244
+ commonTags = filter ( lambda x : str (x ) in childTags , parentTags )
245
+ if not commonTags :
246
+ # Hide that child since it doesn't match any filter
247
+ maya .cmds .setAttr ( childTransform + ".visibility" , 0 )
248
+ else :
249
+ maya .cmds .setAttr ( childNode + ".drawTagsFilter" , " " .join (commonTags ),type = "string" )
250
+
251
+ # Connect child time to its parent so they're in sync
252
+ if not maya .cmds .isConnected ( node + ".outTime" , childNode + ".time" ):
253
+ maya .cmds .connectAttr ( node + ".outTime" , childNode + ".time" , f = True )
254
+
255
+ return fnChild
205
256
206
257
## Expands the scene shape one level down if possible.
207
258
# Returns a list of function sets for the child scene shapes.
@@ -233,54 +284,11 @@ def expandOnce( self ) :
233
284
drawRootBound = maya .cmds .getAttr ( node + ".drawRootBound" )
234
285
drawTagsFilter = maya .cmds .getAttr ( node + ".drawTagsFilter" )
235
286
236
- timeConnection = maya .cmds .listConnections ( node + ".time" , source = True , destination = False , plugs = True )
237
-
238
287
newSceneShapeFns = []
239
288
240
289
for i , child in enumerate ( sceneChildren ):
241
290
242
- if maya .cmds .objExists ( transform + "|" + child ):
243
- shape = maya .cmds .listRelatives ( transform + "|" + child , f = True , type = "ieSceneShape" )
244
- if shape :
245
- fnChild = IECoreMaya .FnSceneShape ( shape [0 ] )
246
- else :
247
- fnChild = IECoreMaya .FnSceneShape .createShape ( transform + "|" + child )
248
- else :
249
- fnChild = IECoreMaya .FnSceneShape .create ( child , transformParent = transform )
250
-
251
- childNode = fnChild .fullPathName ()
252
- childTransform = maya .cmds .listRelatives ( childNode , parent = True , f = True )[0 ]
253
- maya .cmds .setAttr ( childNode + ".file" , sceneFile , type = "string" )
254
- sceneRootName = "/" + child if sceneRoot == "/" else sceneRoot + "/" + child
255
- maya .cmds .setAttr ( childNode + ".root" , sceneRootName , type = "string" )
256
-
257
- index = self .__queryIndexForPath ( "/" + child )
258
- outTransform = node + ".outTransform[" + str (index )+ "]"
259
- if not maya .cmds .isConnected ( outTransform + ".outTranslate" , childTransform + ".translate" ):
260
- maya .cmds .connectAttr ( outTransform + ".outTranslate" , childTransform + ".translate" , f = True )
261
- if not maya .cmds .isConnected ( outTransform + ".outRotate" , childTransform + ".rotate" ):
262
- maya .cmds .connectAttr ( outTransform + ".outRotate" , childTransform + ".rotate" , f = True )
263
- if not maya .cmds .isConnected ( outTransform + ".outScale" , childTransform + ".scale" ):
264
- maya .cmds .connectAttr ( outTransform + ".outScale" , childTransform + ".scale" , f = True )
265
-
266
- maya .cmds .setAttr ( childNode + ".drawGeometry" , drawGeo )
267
- maya .cmds .setAttr ( childNode + ".drawChildBounds" , drawChildBounds )
268
- maya .cmds .setAttr ( childNode + ".drawRootBound" , drawRootBound )
269
-
270
- if drawTagsFilter :
271
- parentTags = drawTagsFilter .split ()
272
- childTags = fnChild .sceneInterface ().readTags ()
273
- commonTags = filter ( lambda x : str (x ) in childTags , parentTags )
274
- if not commonTags :
275
- # Hide that child since it doesn't match any filter
276
- maya .cmds .setAttr ( childTransform + ".visibility" , 0 )
277
- else :
278
- maya .cmds .setAttr ( childNode + ".drawTagsFilter" , " " .join (commonTags ),type = "string" )
279
-
280
- # Connect child time to its parent so they're in sync
281
- if not maya .cmds .isConnected ( node + ".outTime" , childNode + ".time" ):
282
- maya .cmds .connectAttr ( node + ".outTime" , childNode + ".time" , f = True )
283
-
291
+ fnChild = self .createChild ( child , sceneFile , sceneRoot , drawGeo , drawChildBounds , drawRootBound , drawTagsFilter )
284
292
newSceneShapeFns .append ( fnChild )
285
293
286
294
return newSceneShapeFns
0 commit comments