@@ -19,34 +19,38 @@ def removeHiddenInOutliner(allItems):
1919def updateDefaultPrimCandidates (excludeMesh , excludeLight , excludeCamera , excludeStage ):
2020 allItems = cmds .ls (assemblies = True )
2121 excludeList = []
22+
23+ def add_excluded (items ):
24+ for m in items :
25+ rel = cmds .listRelatives (m , parent = True , fullPath = True )[0 ]
26+ excludeList .append (m )
27+ excludeList .append (rel )
28+ if rel .startswith ("|" ):
29+ excludeList .append ((rel .removeprefix ("|" )))
30+
2231 if excludeMesh == "1" :
23- meshes = cmds .ls (type = ('mesh' ), l = True )
24- for m in meshes :
25- excludeList .append (cmds .listRelatives (m , parent = True )[0 ])
32+ add_excluded (cmds .ls (type = ('mesh' ), l = True ))
2633
2734 if excludeLight == "1" :
28- lights = cmds .ls (type = ('light' ), l = True )
29- for l in lights :
30- excludeList .append (cmds .listRelatives (l , parent = True )[0 ])
35+ add_excluded (cmds .ls (type = ('light' ), l = True ))
3136
3237 if excludeCamera == "1" :
33- cameras = cmds .ls (type = ('camera' ), l = True )
34- for c in cameras :
35- excludeList .append (cmds .listRelatives (c , parent = True )[0 ])
38+ add_excluded (cmds .ls (type = ('camera' ), l = True ))
3639 else :
40+ # Note: we still want to exclude the startup cameras even if
41+ # excludeCamera is not set, to avoid exporting them by mistake.
3742 cameras = cmds .ls (type = ('camera' ), l = True )
3843 startup_cameras = []
3944 for c in cameras :
40- if cmds .camera (cmds .listRelatives (c , parent = True )[0 ], startupCamera = True , q = True ):
41- startup_cameras .append (cmds .listRelatives (c , parent = True )[0 ])
45+ camRelatives = cmds .listRelatives (c , parent = True , fullPath = True )
46+ if cmds .camera (camRelatives [0 ], startupCamera = True , q = True ):
47+ startup_cameras .append (camRelatives [0 ])
4248
49+ startup_cameras .extend ([c .removeprefix ("|" ) for c in startup_cameras ])
4350 allItems = list (set (allItems ) - set (startup_cameras ))
4451
4552 if excludeStage == "1" :
46- stages = cmds .ls (type = ('mayaUsdProxyShape' ), l = True )
47- for st in stages :
48- excludeList .append (st )
49- excludeList .append (cmds .listRelatives (st , parent = True )[0 ])
53+ add_excluded (cmds .ls (type = ('mayaUsdProxyShape' ), l = True ))
5054
5155 allItems = removeHiddenInOutliner (list (set (allItems ) - set (excludeList )))
5256 allItems .sort (key = natural_key )
@@ -74,7 +78,7 @@ def _addExclusions(nodeType, excludeParent=False):
7478 nodes = cmds .ls (type = (nodeType ), l = True )
7579 for n in nodes :
7680 if excludeParent :
77- excludeSet .add (cmds .listRelatives (n , parent = True )[0 ])
81+ excludeSet .add (cmds .listRelatives (n , parent = True , fullPath = True )[0 ])
7882 path = _getRelatives (n )
7983 if not path :
8084 continue
0 commit comments