Sun, Oct 6, 2:27 PM 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: batch import


stonemason ( ) posted Tue, 30 September 2008 at 8:02 PM · edited Sun, 06 October 2024 at 2:26 PM

hi guys..I'm wondering if it's possible to have a script do batch imports with Poser?

Cheers
Stefan

Cg Society Portfolio


PhilC ( ) posted Tue, 30 September 2008 at 9:21 PM

Like import all OBJ files from a particular directory?


stonemason ( ) posted Tue, 30 September 2008 at 9:39 PM

hi Phil,
yes..point to a directory & let it load in everything,maybe using the last used import settings?(everything unchecked)
I've got a parented prop set with over 100 parts & importing manually takes forever.

Cg Society Portfolio


PhilC ( ) posted Tue, 30 September 2008 at 10:39 PM
stonemason ( ) posted Tue, 30 September 2008 at 11:31 PM

thanks for looking into this Phil..unfortunately I get the message '0 OBJ files imported'
it allows me to browse & select the folder but nothing imports

using P7 & 6 and selecting a geometrie folder at the root of drive

I should add I know bugger all about Python so it may be something simple I'm missing,

Cg Society Portfolio


PhilC ( ) posted Wed, 01 October 2008 at 12:46 AM

Can you please post a Windows Explorer screen shot showing the OBJ files?

Thanks


stonemason ( ) posted Wed, 01 October 2008 at 12:58 AM
PhilC ( ) posted Wed, 01 October 2008 at 1:44 AM · edited Wed, 01 October 2008 at 1:45 AM

Your files need to have the extension ".obj" or ".OBJ"

Alternatively edit the script so that it will attempt to import every file.

def visit(something, dirname, names):<br></br>
    for name in names:<br></br>
        try:  <br></br>
           
filepath = os.path.join(dirname,name) <br></br>
            importOBJ(filepath)<br></br>
        except:<br></br>
            pass


nruddock ( ) posted Wed, 01 October 2008 at 3:03 AM · edited Wed, 01 October 2008 at 3:12 AM

Quote - Your files need to have the extension ".obj" or ".OBJ"

They do have the right extension, but Windows Explorer is set to hide them.
This doesn't affect anything but what it displays.

Although it doesn't appear necessary in this case, but why not use string.split(name,".")[1].lower() == "obj" as the extension test to cover odd combinations of cases.


PhilC ( ) posted Wed, 01 October 2008 at 6:05 AM

Originally I was using :-

if string.split(name,".")[1] == "obj" or string.split(name,".")[1] == "OBJ":

which is pretty much the same thing unless the extension was "oBj" which though possible I felt unlikely.

I appreciate that the extension has been hidden. It should indeed not make a difference but the script was failing to import the files so I used the try/except edit to take the file type out of the equation.

The next questions to ask would be:-

Are they well formed OBJ files?
Can they be imported manually?
Has the latest Poser service release been installed?


semidieu ( ) posted Wed, 01 October 2008 at 6:26 AM

Why don't you use:

os.path.splitext(filename)[1].lower()=='.obj'

This way, you will be sure to have the correct extension!

Another question Stefan: do you want to load all obj in the folder or choose a selection of props located in a folder ?


PhilC ( ) posted Wed, 01 October 2008 at 7:42 AM

OK duh!

This line was missing from the top of the script:-

scene = poser.Scene()

I've also changed the extension test to include the mixed case scenario as opposed to the either upper or lower case that I had originally.

http://www.philc.net/forum/viewtopic.php?p=12956

The script worked on my machine because I had previously been running any number of scripts that had set this variable. I found the error when I ran the script on a different computer after a reboot.


stonemason ( ) posted Wed, 01 October 2008 at 7:56 AM

hey that new version works perfectly...117 props loaded... whilst making a coffee :)

thank you very much Phil!

semidieu..I wanted everything from one folder loaded,but having an option to selected a group of objects might make the script handy for others.
I always dread having to manually bring in each part to Poser as my sets are so big,so many parts,
Phil you've saved me from a hell of a repetetitve task..I owe you one :)

Cheers
Stefan

Cg Society Portfolio


semidieu ( ) posted Wed, 01 October 2008 at 1:15 PM

I'll make this script and will post it somewhere (rdna).


stonemason ( ) posted Wed, 01 October 2008 at 10:09 PM

hey if your working on import scripts..how about a batch export while your at it?..not really anything I have an immediate use for but to fill out the suite it would be a cool adition.

Cg Society Portfolio


semidieu ( ) posted Thu, 02 October 2008 at 12:58 PM

Ok... I'll do it :D


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.