Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / how to select an existing set in my scene?
  RSS 2.0 ATOM  

how to select an existing set in my scene?
Rate this thread
 
23048
 
Permlink of this thread  
avatar
  • Location: Los Angeles CA
  • Total Posts: 99
  • Joined: 16 May 2008 02:40 AM

Hi,

I’m just trying to hide an existing set in my scene, but having trouble. Here is what I have.

from pyfbsdk import *

mySet FBSet('name of an existing set in my scene')
mySet.Visibility False

I think the first line is the problem. I think that is the class constructor used to create a new set. Is there an easy way just to select an existing set?

I don’t think I can use FBFindModelByName since a set isn’t a model right?

thx,
Brian



MotionBuilder 7.5 thru ...
3dsMax 2.5 thru ...

Replies: 0
avatar
  • Kodeki
  • Posted: 20 February 2009 02:22 PM

I’m kind of new to this but here’s some help.

mySet FBSet('name of an existing set in my scene')

...this actually creates a new Set. If you want to select the first Set in your scene use…

mySet FBSystem().Scene.Sets[0]

If you want to select the second Set replace the [0] with [1]. I’m not so familiar with choosing by name yet but that is possible.

To set the visibility you’ll want to access the PropertyList, use the Find function to pick out Visibility and set the value using Data…

mySet.PropertyList.Find('Visibility').Data False

Hope that helps, as I said I’m kind of new to this so there may be better ways.



Replies: 0
avatar

hey thanks. so i tried:

from pyfbsdk import *

mySet FBSystem().Scene.Sets[0] 
mySet
.PropertyList.Find('Visibility').Data False

but no luck…



MotionBuilder 7.5 thru ...
3dsMax 2.5 thru ...

Replies: 0
avatar
  • Kodeki
  • Posted: 20 February 2009 04:33 PM

That’s too bad; maybe there are no Sets in your scene now?

Anyway this should work better as it’ll search for a Set by name…

from pyfbsdk import *

aSets FBSystem().Scene.Sets

for aLoop in aSets:
    if 
aLoop.Name.find("name of an existing set in my scene") != -1:
        
aLoop.PropertyList.Find('Visibility').Data False 
    
else:
        print

Notice that the .find in the first line of the loop is lower case, this is important though I can’t explain why yet :-/

!= -1: is a round about way of saying, is true.

It seems that there needs to be a least something after the else: statement so I add a print, there’s probably a better way of doing this.



Replies: 0
avatar

ok thx, this now works, notice the new location of [0]

mySet FBSystem().Scene.Sets 
mySet[0]
.PropertyList.Find('Visibility').Data False

and this also works:

aSets FBSystem().Scene.Sets

for aLoop in aSets:
    if 
aLoop.Name.find('clapper 1') != -1:
        
aLoop.PropertyList.Find('Visibility').Data False
    
if aLoop.Name.find('calibratorB 1') != -1:
        
aLoop.PropertyList.Find('Visibility').Data False
    
else:
        print


MotionBuilder 7.5 thru ...
3dsMax 2.5 thru ...

Replies: 0
avatar
  • Kodeki
  • Posted: 20 February 2009 07:32 PM

Glad that worked :-)

I wonder why the positioning of the [0] made a difference. I’m using MB2009, maybe that’s it?



Replies: 0
avatar

could be… i’m on MB 7.5 x2



MotionBuilder 7.5 thru ...
3dsMax 2.5 thru ...

Replies: 0