Mon, Sep 9, 5:24 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 08 5:10 pm)

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: os.path.join and Poser 6 Mac


semidieu ( ) posted Sat, 05 July 2008 at 7:41 AM · edited Fri, 06 September 2024 at 4:28 AM

OK... here is a simple question and I cannot answer...

Say I have a path that has been read from a TEXT file.

ROOT = poser:poser 6:runtime:libraries:props

and another path like this:

SUB = hello:world

Then, when I use:

os.path.join(ROOT, SUB)

it returns only the SUB path (hello:world)

Is there something wrong ?

I know I can use:

ROOT + os.sep + SUB

but it would need a LOT of changing (as the script was made for Poser 7 and this problem does not appear on P7 Mac !)

Thanks :D


nruddock ( ) posted Sat, 05 July 2008 at 8:48 AM

Quote - On the Mac, relative paths begin with a colon, but as a special case, paths with no colons at all are also relative.
Anything else is absolute (the string up to the first colon is the volume name)

Above quote is from the docstring for join in macpath.py

Quote - If any component is an absolute path, all previous components are thrown away, and joining continues.

and this one from the docs for os.path.join

What this suggests you need to do is put all the subdirectories as individual arguments to the join call.
So instead of ROOT = "poser:poser 6:runtime:libraries:props" SUB = "hello:world" thePath = os.path.join(ROOT, SUB)

use ROOT = "poser:poser 6:runtime:libraries:props" SUB1 = "hello" SUB2 = "world" thePath = os.path.join(ROOT, SUB1, SUB2)

so that all the SUBs are correctly treated as relative paths.

I don't have a Mac, but code inspection seems sufficient in this case.
Putting some print statements in macpath.py would be the best way to go if the above doesn't solve the problem.


semidieu ( ) posted Sat, 05 July 2008 at 8:55 AM

OK... I'll try this.

Thanks :D


adp001 ( ) posted Sat, 05 July 2008 at 9:19 AM

As I have learned, for Macs a relative path starts with ":".
For the above, ":hello:world" should allow correct path joining.




semidieu ( ) posted Sat, 05 July 2008 at 9:28 AM

Oooooooh... Could this be so simple :)

I'll make the correction and will see with my tester if it solves it (as I do not have a mac too).


Miss Nancy ( ) posted Sun, 06 July 2008 at 1:45 PM

semi, it could also be as simple as the problem with tkinter and Poser 6 in OS X that
prevents most or all python scripts from running in said app.  ask your tester if he/she
has ever run any scripts successfully in Poser 6 OS X.  if the answer is "yes", then
request some screenshots of said scripts in action as evidence that they really work.



semidieu ( ) posted Sun, 06 July 2008 at 1:57 PM

Thanks for the info... I know about the TKinter... This will be the next step: an alternative to this to make my script work in P6 mac...


Miss Nancy ( ) posted Sun, 06 July 2008 at 4:00 PM

Attached Link: http://www.renderosity.com/mod/forumpro/showthread.php?message_id=2178409&ebot_calc_page#message_2178409

one of the representatives for whomever owned Poser 6 during beta testing made a public statement, upon the release of the first version of poser 6 OS X , apologising for the tkinter deficiency.  whilst they didn't provide a fix for this in poser 6, e-f remedied the python script problem with the first release of poser 7, OS X.  *quel dommage* that your tester was unaware of this.



semidieu ( ) posted Sun, 06 July 2008 at 4:12 PM

Thanks for the links :D

I read this thread a loooooong time ago, but it was before I really started writing python scripts ;)


semidieu ( ) posted Thu, 10 July 2008 at 3:18 PM

Just to let you know that adding the : at the beginning worked ! Thanks.


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.