Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
this is something I am still working on - but you may be able to use it for what you need
'''coded by structure'''
#----------------------#
# imports
import poser, os, os.path
# set Variables
scene=poser.Scene()
# dictionaries and lists
suflist = { 0 : '.cr%s',
1 : '.pz%s',
2 : '.fc%s',
3 : '.hr%s',
4 : '.hd%s',
6 : '.lt%s',
7 : '.cm%s',
8 : '.mt%s',
9 : '.mc%s',
10 : '.pz%s',
11 : '.pp%s'}
s=[2,3,5,6,'z']
library = ['Character','Pose','Face','Hair','Hand','light','Camera','Material','Material','Scene','Props']
# functions
def DoSomething(item, c):
folder = os.path.join(poser.Libraries()[0], 'runtime','Libraries',library[c])
print folder
# main
item = 'material.pp2'
c=0
for i in suflist:
t=0
for a in range(len(s)):
try:
if item.endswith(suflist[c] %s[t]):
print suflist[c] %s[t], c
DoSomething(item, c)
except:
pass
t+=1
c+=1
Locked Out
Thanks, that looks like an elegant way of dealing with the Poser library file types. I'll reflect on it in due course.
A little more on the project - it seems that although LoadLibraryFigure() will indeed load any object, it doesn't pass through parenting information from smart props or hair, nor does it replace existing hair. I guess I should use the specific load method for each one to get those behaviours.
updated script - this appears to be working correctly
import poser, os, os.path, string
# Set Variables
scene=poser.Scene()
path=None
libs=['camera','character','face','hair','hand','light','pose','props','materials']
ext={0:'.cm%s',1:'.cr%s',2:'.fc%s',3:'.hr%s',4:'.hd%s',5:'.lt%s',6:'.pz%s',7:'.pp%s',8:'.mc%s',9:'.mt%s'} #,'.png','.rsr'}
s=['2','3','5','6','z']
# Select Folder
def GetWorkingFolder(link):
parentDialog=0
message='Select Folder'
Dir=os.path.join(poser.Libraries()[0], 'Runtime')
startDir=os.path.join(Dir,'Libraries', link)
wDir=poser.DialogDirChooser(parentDialog,message,startDir)
wDir.Show()
WorkingFolder=wDir.Path()
return WorkingFolder
# what to do with what we found ?
def DoSomething(item, c):
if c==9:c=8
print 't',item, c, libs[c]
# create Choice Dialog
link=poser.DialogSimple.AskMenu("Choose :","Which Library ?",libs)
# find the correct starting folder
for l in libs:
if not link == None:
if l == link:
path = GetWorkingFolder(l)
# discover files
if not path == None:
items=os.listdir(path)
for item in items:
c=0
for i in ext:
t=0
for a in range(len(s)):
try:
if c==9 : c-8
if item.endswith(ext[c] %s[t]):
DoSomething(item, c)
except:
pass
t+=1
c+=1
Locked Out
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.
I'm trying to devise a script that will let me browse for and load any library file.
I can use LoadLibraryFigure( path ) to load any sort of geometry-based content: figures, props or hair. So far, so good.
Contrary to what I've read elsewhere, I seem to have to use the correct specific method for modifier types: LoadLibraryPose for poses, LoadLibraryLight for lights and so on, although I haven't tested every permutation yet. If this is true, then I should add some code to detect the file extension that I choose and switch to using the right load method - but if you know a better way, please let me know!
A bigger problem, in Poser 7 anyway, is that there isn't a LoadLibraryMaterial method - or is there? It isn't in the Python Methods manual. I tried
scene.LoadLibraryMaterial( path )
but it didn't do anything. However there wasn't a syntax error either, so maybe the method exists but is broken?