RAMWorks opened this issue on Aug 20, 2020 · 16 posts
structure posted Thu, 20 August 2020 at 6:08 PM Forum Coordinator
this is not perfect but it works
# -*- coding: utf-8 -*-
''' ©2014 structure '''
import poser, wx, wx.xrc, string, os, os.path
def IsFocal(parm):
if printdebug:print 'IsFocal'
if parm.TypeCode()==12: return True
def cancel_Point_At(camera):
if printdebug:print 'cancel_Point_At'
for parm in camera.Parameters():
if parm.TypeCode() == 66:
parm.SetValue(0.0)
def FindCamera(figure, part):
# decide on camera
if printdebug:print 'FindCamera'
for Camera in scene.Cameras():
if Camera.InternalName()=='MAIN_CAMERA':
poser.Scene().SetCurrentCamera(Camera)
Camera.Restore()
for parm in Camera.Parameters():
if IsFocal(parm):
resetparm=parm.Value()
parm.SetValue(65)
# Camera.ParameterByCode(poser.kParmCodePOINTAT).SetValue(0.0)
cancel_Point_At(Camera)
scene.SelectFigure(scene.Figure(figure.Name()))
scene.SelectActor(scene.Actor(part.Name()))
scene.FrameSelected()
scene.DrawAll()
return Camera, resetparm
def GetFileList(folder):
if printdebug:
print 'GetFileList'
listoffiles=os.listdir(folder)
return listoffiles
def GetPoseFolder(startDir):
if printdebug:
print 'GetPoseFolder'
dialog = wx.DirDialog(None, "Choose a directory:",style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
dialog.SetPath(startDir)
if dialog.ShowModal() == wx.ID_OK:
wD = dialog.GetPath()
return wD
else:
ShowAlert('User Cancelled',None,'Complete')
return None
def IsEmpty(scene):
if scene.Figures():return False
return True
def render(figure, filename):
ext = SplitExtension(filename,1)
outputfile = SplitExtension(filename,0)
outputfile += '.png'
scene.LoadLibraryPose(filename)
figure.DropToFloor()
scene.Render()
scene.SaveImage ('png',outputfile)
def setrenderopts( x=0 , y=0 , gi=0 , sss=0 , shadows=0 ):
scene.SetOutputRes( x , y )
scene.CurrentFireFlyOptions().SetUseGI(gi)
scene.CurrentFireFlyOptions().SetUseSSS(sss)
scene.SetRenderCastShadows(shadows)
def ShowAlert(alertmessage, error=None, title=None):
APPNAME=u''
if title == None: title = '%s ' % APPNAME
msg = wx.MessageDialog(None, alertmessage, caption=title, style=wx.OK|wx.STAY_ON_TOP)
msg.ShowModal()
def SplitExtension(file, mode=0):
return os.path.splitext(file)[mode]
def StripExtension(file):
return os.path.splitext(file)[0]
PoseFolder = None
scene=poser.Scene()
types = ('.pz2','.p2z')
Preferences = poser.PrefsLocation()
cam=scene.CurrentCamera()
rDas=scene.RenderDimAutoscale()
x,y=scene.OutputRes()
GI=scene.CurrentFireFlyOptions().UseGI()
SSS=scene.CurrentFireFlyOptions().UseSSS()
shadows=scene.RenderCastShadows()
pp2=[]
png=[]
ground=scene.Actor('GROUND')
ViC=ground.VisibleInCamera()
ground.SetVisibleInCamera(0)
startDir=None
libraries=poser.Libraries()
resetparm = 0
setrenderopts (200,200) # this is your render size
startDir = os.path.join(poser.Libraries()[0],'Runtime','Libraries','Pose')
if not IsEmpty(scene):
figure = scene.CurrentFigure()
figure.Restore()
scene.SelectActor(scene.Actor('Body'))
actor = scene.CurrentActor()
part=actor
camera, resetparm = FindCamera(figure, part)
cancel_Point_At(camera)
PoseFolder=GetPoseFolder(startDir)
if not PoseFolder==None:
filelist = GetFileList(PoseFolder)
for i in filelist:
if i.endswith( types ):
file = os.path.join(PoseFolder,i)
if os.path.exists(file):
render(figure, file)
ground.SetVisibleInCamera(ViC)
setrenderopts( x , y , GI , SSS , shadows )
scene.SetCurrentCamera(cam)
scene.SetRenderDimAutoscale(rDas)
printdebug = False
figure.Restore()
cam.Restore()
cancel_Point_At(cam)
if cam == camera:
for parm in cam.Parameters():
if IsFocal(parm):
parm.SetValue(resetparm)
scene.DrawAll()
Locked Out