Forum: Poser Python Scripting


Subject: Any idea how enable Animation Toggle option via script ?

andygraph opened this issue on Feb 10, 2014 · 55 posts


structure posted Sun, 30 March 2014 at 6:07 PM Forum Coordinator

ok - this should work

import poser , os.path

act=scene.CurrentActor()
sdir = os.path.join('c:','users')

def IsValid(actor):
    if actor !='' and actor !=None:
        if actor.IsLight() or actor.IsCamera():
            return False
        else:
            return True

def ImportObj(fName):
    imex = scene.ImExporter()
    options = imex.ImportOptions('obj', None)
    options[poser.kImOptCodeMAKEPOLYNORMSCONSISTENT] = 0
    options[poser.kImOptCodeOFFSETZ] = 0.0
    options[poser.kImOptCodeOFFSETY] = 0.0
    options[poser.kImOptCodeOFFSETX] = 0.0
    options[poser.kImOptCodeFLIPUTEXTCOORDS] = 0
    options[poser.kImOptCodeWELDIDENTICALVERTS] = 0
    options[poser.kImOptCodeCENTERED] = 0
    options[poser.kImOptCodePERCENTFIGSIZE] = 0
    options[poser.kImOptCodeFLIPVTEXTCOORDS] = 0
    options[poser.kImOptCodeFLIPNORMS] = 0
    options[poser.kImOptCodePLACEONFLOOR] = 0
    imex.Import('obj', 'File Format Wavefront', fName, options)

actlist=[]
lof=os.listdir(sdir)
for f in lof:
    if f.endswith('.obj'):
        fName = os.path.join(sdir, f)
        try:
            ImportObj(fName)
        except:
            print 'error on ', f
print 'done'

[actlist.append(act) for act in scene.Actors() if IsValid(act)]
la=len(actlist)

for nf in range(la):
    actlist[nf].SetVisible(1)
    scene.SetFrame(nf+1)
    for i in range(la):
        if not i == nf:
            actlist[i].SetVisible(0)
            scene.DrawAll()
    for x in range(10000000):
        x+=1
    x=0

#========================================================#

you may need to edit the IsValid function to add more things you do not want to change in your scene

eg.

if actor.Name()=='Ground':

    return False

 

Locked Out