PDA

View Full Version : Removing groups using Python


LoneCanuck
04-26-2007, 02:57 PM
Hello,

I am trying to create a script that removes all the groups in a given scene. The groups look like this:

Main Group
...Geo Group
...Joint Group
...Null Group

So the Geo, Joint, and Null groups are nested under a Main Group

When I run this script:
======================
from pyfbsdk import *

lScene = FBSystem().Scene
allGroups = lScene.Groups
for group in allGroups:
...print group
...group.FBDelete()
del (group)
====================
The script stops after removing 2 groups. If I run it again, it removes one group. Run it again, and the last group is deleted. Is there any way to just remove all the groups in one pass?

-LoCK-

Neill
04-27-2007, 09:49 AM
Hello,

I am trying to create a script that removes all the groups in a given scene. The groups look like this:

Main Group
...Geo Group
...Joint Group
...Null Group

So the Geo, Joint, and Null groups are nested under a Main Group

When I run this script:
======================
from pyfbsdk import *

lScene = FBSystem().Scene
allGroups = lScene.Groups
for group in allGroups:
...print group
...group.FBDelete()
del (group)
====================
The script stops after removing 2 groups. If I run it again, it removes one group. Run it again, and the last group is deleted. Is there any way to just remove all the groups in one pass?

-LoCK-

Try something like this

lScene = FBSystem().Scene
allGroups = lScene.Groups
for group in allGroups:
...print group
...group.FBDelete()
...del (group)

LoneCanuck
04-27-2007, 04:04 PM
Heh. Not quite. That might work for flat hieararchy Groups but nested ones...not so much.

This one works for real.

--------------------------------

from pyfbsdk import *

lScene = FBSystem().Scene

allGroups = lScene.Groups

for i in range(len(allGroups)):

...allGroups[-1].FBDelete()

del ( lScene , allGroups)

--------------------------------

CGTalk Moderation
04-27-2007, 04:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.