BasicOperations/DeletingObjectBasedOnNameSpace.py

BasicOperations/DeletingObjectBasedOnNameSpace.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 
6 # Script description:
7 # Delete selected object that have a specified namespace.
8 #
9 # Topic: NamespaceSelectContent, FBComponent
10 #
11 
12 from pyfbsdk import FBSystem, FBComponent, FBObjectFlag
13 
14 #Change the name of the following value to match your namespace
15 lNamespace = "myNamespace"
16 
17 # Deselect all other objects before selecting objects in the scene
18 for lComp in FBSystem().Scene.Components:
19  if lComp != None and lComp.Selected:
20  lComp.Selected = False
21 
22 # Selects all the objects that have the namespace
23 FBSystem().Scene.NamespaceSelectContent(lNamespace, True)
24 
25 lList = []
26 
27 # Going through all the components in the scene
28 for lComp in FBSystem().Scene.Components:
29  if lComp != None and lComp.Selected and lComp.HasObjectFlags(FBObjectFlag.kFBFlagDeletable):
30  # Appending to list to be deleted after
31  lList.append(lComp)
32 
33 # Delete the components in the list
34 map( FBComponent.FBDelete, lList )
35 
36 # Clean-up
37 del(FBSystem, FBComponent, FBObjectFlag, lList, lComp)