Tue, Oct 22, 9:50 AM CDT

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



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


  • 1
  • 2
andygraph ( ) posted Mon, 10 February 2014 at 2:45 AM · edited Tue, 22 October 2024 at 9:22 AM

Any idea ?


timarender ( ) posted Mon, 10 February 2014 at 2:51 PM

Is that the purpose of the method "SetAnimated"?


andygraph ( ) posted Mon, 10 February 2014 at 3:41 PM

I have a script but dont know where insert SetAnimated, if its work ...


andygraph ( ) posted Mon, 10 February 2014 at 3:53 PM

this script is for import obj sequence and hide/show frame by frame

its work for import obj, fine but the objs are all hide and don't have show enable on frame:

 

file_001.obj     show in frame 1

file_002.obj     show in frame 2

..

 

i believe its because the animaion toggle is not enable in script


markschum ( ) posted Mon, 10 February 2014 at 6:56 PM

try changing the lines that use SetOnOff  to SetVisibleInRender

 

this parameter does not need to be activated for animations.


andygraph ( ) posted Tue, 11 February 2014 at 2:47 AM · edited Tue, 11 February 2014 at 2:54 AM

try it, change nothing :-(

 

obj series importer

import poser, os

scn = poser.Scene()
fig = scn.CurrentFigure()

sdir = "C:UsersAndryDesktopTEST"

frame = 0
myfiles = os.listdir(sdir)
print myfiles
for myfile in myfiles:
if myfile[-3:] == "obj":
cfile = os.path.join(sdir, myfile)
try:
print 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)
act = scn.CurrentActor()
act.SetName(myfile[:-4])
act.SetVisibleInRender(1)
frame = frame + 1
scn.SetFrame(frame)
act.SetVisibleInRender(0)
if frame > 2:
scn.SetFrame(frame - 2)
act.SetVisibleInRender(0)
scn.SetFrame(frame)
except:
print "t error on ",myfile
print "Done"

 

 

 

 


andygraph ( ) posted Tue, 11 February 2014 at 4:21 AM

file_501720.jpg

If a check the animation toggle it show the visible dial ..

so i believe if is possible add a visible dial to prop via script is possible animate it.


andygraph ( ) posted Thu, 13 February 2014 at 5:03 AM

no solution ?

pleeeeease :-(


structure ( ) posted Sat, 29 March 2014 at 10:55 AM
Forum Coordinator

SetAnimated is listed under Shader Node Input methods.

I think you would be better writing a toggle function. I am not entirely sure what exactly you are after, but maybe something like this would work

import poser
scene=poser.Scene()

def toggleanim(scene,framecount,toggle=False):
    scene.SetFrame(0)
    if toggle:
        for frame in range(frames):
            scene.SetFrame(frame)
    else:
        return False

toggleanim(scene, framecount, True)

the third value ( True ) should overwrite the default of False and therefore the animation should toggle (in this case frame by frame)

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 7:54 AM

How i can add this script in obj loader sequence script ?


structure ( ) posted Sun, 30 March 2014 at 8:20 AM · edited Sun, 30 March 2014 at 8:28 AM
Forum Coordinator

after looking at your code it seems you want to make an actor invisible in certain frames and visible in others so there are 3 ways to accomplish this :

as markschum said you can use

setvisibleinrender

or you can use

SetVisible

SetVisibleInCamera

import poser
scn=poser.Scene()
def ActVisible(act,toggle,frame):
    scene.SetFrame(frame)
    act.SetVisible(act,toggle,frame)

act = scn.CurrentActor()
act.SetName(myfile[:-4])
ActVisible(act,1,0)
frame = frame + 1
scn.SetFrame(frame)
ActVisible(act,1,frame)
if frame > 2:
    scn.SetFrame(frame - 2)
    ActVisible(act,0,frame)
scn.SetFrame(frame)

both setvisibleinrender and setvisibleincamera will not appear to do anything until you actually render

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 8:31 AM · edited Sun, 30 March 2014 at 8:42 AM

i have wrote:

obj series importer

import poser, os

scn = poser.Scene()
fig = scn.CurrentFigure()

sdir = "C:Users"

frame = 0
myfiles = os.listdir(sdir)
print myfiles
for myfile in myfiles:
if myfile[-3:] == "obj":
cfile = os.path.join(sdir, myfile)
try:
print 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)
act = scn.CurrentActor()
act.SetName(myfile[:-4])
ActVisible(act,1,0)
frame = frame + 1
scn.SetFrame(frame)
ActVisible(act,1,frame)
if frame > 2:
scn.SetFrame(frame - 2)
ActVisible(act,0,frame)
scn.SetFrame(frame)
except:
print "t error on ",myfile
print "Done"

 

 

but i found error message if run this script:

line 33
act.SetName(myfile[:-4])
^
IndentationError: unexpected unindent

 

important i dont want invisible in render only but i need invisible obj in scene:

because I have to load heavy objects and this is the only way to lighten the scene


structure ( ) posted Sun, 30 March 2014 at 8:35 AM · edited Sun, 30 March 2014 at 8:44 AM
Forum Coordinator

i can't tell where your indentations are but it seems to me that line 33 should have the same indentation as line 32

 

this needs editing :-

from

act.SetVisible(act,toggle,frame)

to

act.SetVisible(toggle)

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 8:43 AM

i have repost up


structure ( ) posted Sun, 30 March 2014 at 8:47 AM
Forum Coordinator

if you want the actor to be invisible in the scene SetVisible is the way to go

Locked Out


structure ( ) posted Sun, 30 March 2014 at 8:58 AM · edited Sun, 30 March 2014 at 9:01 AM
Forum Coordinator

def ActVisible(act,toggle,frame):
    scn.SetFrame(frame)
    act.SetVisible(toggle)

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 9:03 AM

now error:

line 6
def ActVisible(act,toggle,frame)
^
SyntaxError: invalid syntax

 

the script:

obj series importer

import poser, os

scn = poser.Scene()
def ActVisible(act,toggle,frame)
scene.SetFrame(frame)
act.SetVisible(toggle)
fig = scn.CurrentFigure()

sdir = "C:Users"

frame = 0
myfiles = os.listdir(sdir)
print myfiles
for myfile in myfiles:
if myfile[-3:] == "obj":
cfile = os.path.join(sdir, myfile)
try:
print 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)
act = scn.CurrentActor()
act.SetName(myfile[:-4])
ActVisible(act,1,0)
frame = frame + 1
scn.SetFrame(frame)
ActVisible(act,1,frame)
if frame > 2:
scn.SetFrame(frame - 2)
ActVisible(act,0,frame)
scn.SetFrame(frame)
except:
print "t error on ",myfile
print "Done"

 

 


structure ( ) posted Sun, 30 March 2014 at 9:10 AM
Forum Coordinator

there is a colon :  missing off the end of your line

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 9:15 AM

error here:

line 7
scn.SetFrame(frame)
^
IndentationError: expected an indented block

 

the script:

obj series importer

import poser, os

scn = poser.Scene()
def ActVisible(act,toggle,frame):
scn.SetFrame(frame)
act.SetVisible(toggle)
fig = scn.CurrentFigure()

sdir = "C:Users"

frame = 0
myfiles = os.listdir(sdir)
print myfiles
for myfile in myfiles:
if myfile[-3:] == "obj":
cfile = os.path.join(sdir, myfile)
try:
print 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)
act = scn.CurrentActor()
act.SetName(myfile[:-4])
ActVisible(act,1,0)
frame = frame + 1
scn.SetFrame(frame)
ActVisible(act,1,frame)
if frame > 2:
scn.SetFrame(frame - 2)
ActVisible(act,0,frame)
scn.SetFrame(frame)
except:
print "t error on ",myfile
print "Done"

 

 


structure ( ) posted Sun, 30 March 2014 at 9:18 AM
Forum Coordinator

this is how I would write it - all the indentations are correct

import poser, os,os.path

scn = poser.Scene()
fig = scn.CurrentFigure()

def ActVisible(act,toggle,frame):
    scn.SetFrame(frame)
    act.SetVisible(toggle)

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)
    
        act = scn.CurrentActor()
        act.SetName(myfile[:-4])
        ActVisible(act,1,0)

        frame += 1
        scn.SetFrame(frame)
        ActVisible(act,1,frame)
        if frame > 2:
            scn.SetFrame(frame - 2)
            ActVisible(act,0,frame)
        scn.SetFrame(frame)
    except:
        print 'error on ', myfile
print 'done'

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 9:35 AM

error:

line 32
if myfile.endswith('.obj'):
^
IndentationError: expected an indented block


structure ( ) posted Sun, 30 March 2014 at 9:46 AM
Forum Coordinator

lol - ok - i missed an indent :)

for myfile in myfiles:
    if myfile.endswith('.obj'):
        cfile = os.path.join(sdir, myfile)
        try:
            ImportObj(cfile)
        
            act = scn.CurrentActor()
            act.SetName(myfile[:-4])
            ActVisible(act,1,0)

            frame += 1
            scn.SetFrame(frame)
            ActVisible(act,1,frame)
            if frame > 2:
                scn.SetFrame(frame - 2)
                ActVisible(act,0,frame)
            scn.SetFrame(frame)
        except:
            print 'error on ', myfile
print 'done'

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 11:39 AM · edited Sun, 30 March 2014 at 11:49 AM

sorry but its the same, whats the difference ?

now import the obj sequence and are all visible and the toggle visible key is not check..

 

can i send you a example of a poser project

just i need a mail


structure ( ) posted Sun, 30 March 2014 at 12:40 PM
Forum Coordinator

yes - you can,  but what you must understand is that the visible object will remain visible in all frames (the invisible object will remain invisible in all frames) that is to say -

once it is made visible - it will be visible in every frame from start to finish, likewise if it is invisible it will be invisible in all frames.

the only way to use it in an animation is to set it on and off as you need it

i will sitemail you with an email addy.

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 12:46 PM

yes, the obj is need to be visible only on 1 frame

 

example:

file.001.obj will be visible only on frame 1 invisible on all other frames

file.002.obj will be visible only on frame 2 invisible on all other frames

file.003.obj will be visible only on frame 3 invisible on all other frames

ecc..

 


structure ( ) posted Sun, 30 March 2014 at 12:54 PM
Forum Coordinator

are the files all named with numbers?

Locked Out


structure ( ) posted Sun, 30 March 2014 at 1:03 PM
Forum Coordinator

 

def ActVisible(act,toggle,frame):
    obj=''
    scene.SetFrame(frame)
    for frame in frames:
        if act.Name().endswith(frame):
            act.SetVisible(1)
        else:
            act.SetVisible(0)

 

 

for myfile in myfiles:
    if myfile.endswith('.obj'):
        cfile = os.path.join(sdir, myfile)
        try:
            ImportObj(cfile)
        
            act = scene.CurrentActor()
            act.SetName(myfile[:-4])
            act.SetName(act.Name())+'%03d' % frame

            ActVisible(act,1,0)
            frame += 1
            scene.SetFrame(frame)
            ActVisible(act,1,frame)
            if frame > 2:
                scene.SetFrame(frame - 2)
                ActVisible(act,0,frame)
            scene.SetFrame(frame)
        except:
           

Locked Out


structure ( ) posted Sun, 30 March 2014 at 1:35 PM · edited Sun, 30 March 2014 at 1:41 PM
Forum Coordinator

replace

act.SetName(act.Name())+'%03d' % frame

 with

act=scene.CurrentActor()

act.SetName(myfile[:-4])
name=act.Name()+('n%03d') % frame
act.SetName(name)

and replace

if act.Name().endswith(frame):

with

if act.Name().endswith(str(frame)):

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 1:59 PM · edited Sun, 30 March 2014 at 1:59 PM

nothing .. its the same .. the objs are visible on all frames and no toggle visible key is checked :-(


structure ( ) posted Sun, 30 March 2014 at 2:04 PM
Forum Coordinator

i willl write a script - and post it shortly

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 2:09 PM

MANY THX! Structure ;-)


structure ( ) posted Sun, 30 March 2014 at 2:59 PM · edited Sun, 30 March 2014 at 3:09 PM
Forum Coordinator

the reason nothing is changing is because the script is not moving the animation and the animation is not re-drawing.

this script will do that, but it does not account for lights and cameras.

import poser
scene    =    poser.Scene()
act        =    scene.CurrentActor()
frame     =    0

for act in scene.Actors():
    name = act.Name() +  ' - %03d' % frame
    act.SetName(name)
    frame +=1

for f in range(scene.NumFrames()):
    if act.Name().endswith(str(f)):
        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)):
                scene.SelectActor(scene.Actor(act.Name()))
                act.SetVisible(0)
    scene.DrawAll()

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 3:16 PM

ok, but how can i use this script with import obj sequence script ?

i need only import objs with toggle visible key enable for animation

i dont need light and camera ..


structure ( ) posted Sun, 30 March 2014 at 3:26 PM · edited Sun, 30 March 2014 at 3:27 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


andygraph ( ) posted Sun, 30 March 2014 at 3:32 PM

nothing, its the same no visible animation

please can i send to you a example about want i need ?


structure ( ) posted Sun, 30 March 2014 at 3:37 PM
Forum Coordinator

sure thing - i sent you a sitemail earlier

Locked Out


andygraph ( ) posted Sun, 30 March 2014 at 3:54 PM

i send you now a zip file


structure ( ) posted Sun, 30 March 2014 at 4:03 PM
Forum Coordinator

ok

Locked Out


structure ( ) posted Sun, 30 March 2014 at 6:07 PM · edited Sun, 30 March 2014 at 6:08 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


structure ( ) posted Sun, 30 March 2014 at 6:53 PM
Forum Coordinator

this is what this script does.

Locked Out


andygraph ( ) posted Mon, 31 March 2014 at 2:05 AM · edited Mon, 31 March 2014 at 2:09 AM

error:

line 3, in
act=scene.CurrentActor()
NameError: name 'scene' is not defined

 

but i need run this script then to have import obj sequence ?

because the project will be huge for work then i have import all objs


structure ( ) posted Mon, 31 March 2014 at 2:09 AM
Forum Coordinator

add

scene=poser.Scene()

near top

Locked Out


andygraph ( ) posted Mon, 31 March 2014 at 2:16 AM · edited Mon, 31 March 2014 at 2:17 AM

same error:

line 3, in
act=scene.CurrentActor()
NameError: name 'scene' is not defined

 

 

this is the script:

 

import poser , os.path

act=scene.CurrentActor()
scene = poser.Scene ()
sdir = "C:SEQFOLDER"

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


structure ( ) posted Mon, 31 March 2014 at 2:21 AM
Forum Coordinator

scene = poser.Scene()

needs to be above

act=scene.CurrentActor()

Locked Out


andygraph ( ) posted Mon, 31 March 2014 at 2:26 AM

now import the seq,  but all props are invisible and the last is visible

the toggle visible key is not checked again on all props


structure ( ) posted Mon, 31 March 2014 at 2:32 AM
Forum Coordinator

set the delay

for x in range(10000000):

the animation will play, I can't set the key to checked atm, but this script works as you move through the frames - it makes the next prop visible and the last prop invisible.

other than that, I am at a loss to understands what you are after,

Locked Out


andygraph ( ) posted Mon, 31 March 2014 at 2:39 AM · edited Mon, 31 March 2014 at 2:40 AM

x in range is set to (10000000) now

 

no different is there

the script dont work with me

anyway if the toggle visible key is not checked on any obj in scene no visible animation feature will be there, the real problem has always been there.


structure ( ) posted Mon, 31 March 2014 at 2:43 AM · edited Mon, 31 March 2014 at 2:44 AM
Forum Coordinator

using the toggle visible key is apparently the same as setvisible, I can't find any other way to do this - sorry.

Locked Out


andygraph ( ) posted Mon, 31 March 2014 at 2:44 AM

my idea is import 3d fluid simulation or other 3d simulation into poser through a obj sequence


andygraph ( ) posted Mon, 31 March 2014 at 2:50 AM

"setvisible" dont give animation feature.

For have visible animation is need check the "toggle visible key", first to give any keyframe via script.

just is need know the python command for active the "toggle visible key"

 

MANY, MANY THX for your time Structure, you are a FRIEND! ;-)


structure ( ) posted Mon, 31 March 2014 at 2:57 AM
Forum Coordinator

there are a few keywords that deal with keyframes

NextKeyFrame

NextKeyFrameAll

PrevKeyFrame

PrevKeyFrameAll

AddKeyFrame

DeleteKeyFrame

(there are probably more than this)

Locked Out


  • 1
  • 2

Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.