andygraph opened this issue on Feb 10, 2014 · 55 posts
structure posted Sun, 30 March 2014 at 3:26 PM Forum Coordinator
import poser, os,os.path
scn = poser.Scene()
fig = scn.CurrentFigure()
def IsValid(actor):
if actor !='' and actor !=None:
if actor.IsLight() or actor.IsCamera():
return False
else:
return True
def ActVisible():
for act in scene.Actors():
act.SetName(myfile[:-4])
name = act.Name() + ' - %03d' % frame
if IsValid(act):
act.SetName(name)
frame +=1
for f in range(scene.NumFrames()):
if act.Name().endswith(str(f-1)) and IsValid(act):
scene.SetFrame(f)
scene.SelectActor(scene.Actor(act.Name()))
act.SetVisible(1)
else:
for act in scene.Actors():
if not act.Name().endswith(str(f-1)) and IsValid(act):
scene.SelectActor(scene.Actor(act.Name()))
act.SetVisible(0)
scene.DrawAll()
def ImportObj(cfile):
imex = scn.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', cfile, options)
sdir = os.path.join('c:', os.sep , 'users')
frame = 0
myfiles = os.listdir(sdir)
print myfiles
for myfile in myfiles:
if myfile.endswith('.obj'):
cfile = os.path.join(sdir, myfile)
try:
ImportObj(cfile)
except:
print 'error on ', myfile
ActVisible
print 'done'
Locked Out