Thu, Nov 28, 9:13 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2024 Nov 28 11:20 am)



Subject: Poser ScriptsMenu Panel


Netherworks ( ) posted Mon, 05 April 2010 at 3:56 PM · edited Thu, 28 November 2024 at 9:11 PM

Click for Download page

  • Requirements +

Poser 8 or Poser Pro 2010 (or later)
Written on Windows PC, untested but theoretically works on Mac.

  • Purpose +

To replicate Poser's Scripts Menu in a floating/dockable panel and to provide some additional functions when working with python scripts.

  • Appearance +

In an attempt at a more seamless integration with Poser's existing panels, there is no docked border and background colour is set to that of other panels.  Folder color is darker with yellow text.  Script color is lighter with white text.  The .py and .pyc extensions are hidden to match the scripts menu.

  • Usage +

Simply double-click to run a script or open a folder.  The plus boxes on the left side can also be used to expand or collapse folders.

A menu is available via right-click.

Copy path to the clipboard (original) - works with files and folders

Refresh Folder and Tree (original) - you can refresh the individual folders or tree if you have made changes outside of Poser.

Browse with Explorer (new) - windows users can browse script folders in Window's Explorer.  Similar functionality is implemented for mac users (untested).

Collapse All (new) - Collapses all expanded folders.

Edit Script (new) - scripts with a .py extension can be edited with your file editor of choice.  File editor is defined by using "Set Python Editor", which allows you to browse to an .exe or .app installed on your system.  The script remembers which editor you have set between poser sessions.

Comments and suggestions are always welcome!

Based on ORIGINAL WORK done by Dizzi, a modification done to ScriptsMenu v1.1.  Code redistributed with permission.

.


Victoria_Lee ( ) posted Mon, 05 April 2010 at 4:23 PM

Very cool, Jim.   Is it available now and, if so, where?

Hugz from Phoenix, USA

Victoria

Remember, sometimes the dragon wins. Correction: MOST times.


Netherworks ( ) posted Mon, 05 April 2010 at 4:47 PM · edited Mon, 05 April 2010 at 4:48 PM

Yep, just Click the Pic :D

.


Victoria_Lee ( ) posted Mon, 05 April 2010 at 4:52 PM

Kewl!!  Got it.  Thanks.

Hugz from Phoenix, USA

Victoria

Remember, sometimes the dragon wins. Correction: MOST times.


hborre ( ) posted Mon, 05 April 2010 at 6:36 PM

Thanks.  This looks very convenient.


MarianneR ( ) posted Tue, 06 April 2010 at 2:49 PM

The script doesn't behave on my Mac with PP2010.  When I double-click a script nothing happens at all - it doesn't work and I get no error messages.

The script allows me to choose a python editor and the "Edit script" option in the menu isn't greyed out anymore but I can't actually edit anything - when I choose edit nothing happens.

I downloaded Dizzi's script as well and it seems to work, at least the simple scripts I tried with it: 

 


Netherworks ( ) posted Tue, 06 April 2010 at 5:53 PM

Quote - The script doesn't behave on my Mac with PP2010.  When I double-click a script nothing happens at all - it doesn't work and I get no error messages.

The script allows me to choose a python editor and the "Edit script" option in the menu isn't greyed out anymore but I can't actually edit anything - when I choose edit nothing happens.

I downloaded Dizzi's script as well and it seems to work, at least the simple scripts I tried with it: 

Hmm...

Well if you are willing I can get with you via email and see if I can get it to work better with mac.  I don't have a mac to test with locally so I had to make some guesses.  Shoot me a Rendo pm if you are interested.

.


IsaoShi ( ) posted Tue, 06 April 2010 at 6:53 PM · edited Tue, 06 April 2010 at 6:55 PM

file_450783.png

I'm on Mac. I've put some debugging prints into the EvtExec routine to print out the values of pathPyc and pathPy. See screenshot. It seems the path to the scripts is being built incorrectly.

Hope this gives a clue...

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


IsaoShi ( ) posted Tue, 06 April 2010 at 7:12 PM

I can get it to run scripts by taking the appended 'ScriptsMenu' text out of the 'self.root = ' string assignment (in the class definition), but of course the Menu then shows the contents of the poserScripts folder instead of the ScriptsMenu folder.

I can't do any more detective work tonight (or rather, this morning)... I'm off to bed.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Tue, 06 April 2010 at 7:46 PM

It's cool, thanks for your help so far.

self.root = os.path.join(os.path.dirname(poser.AppLocation()), 'Runtime', 'Python', 'poserScripts', 'ScriptsMenu')  code is identical to Dizzi's script

that "should" be saying find the location of poser.exe or poserpro.exe and build a path adding Runtime:Python:poserScripts:ScriptsMenu

Is the ScriptsMenu folder somewhere different on mac?

From your debug info, I don't know why it's adding scriptsmenu twice..

The changes here (pathPyc, pathPy), were added to detect if that extension exists to the particular file it's trying to run since I reduced the filenames from MyScript.py (for example) to MyScript.  It's kind-of a "kludge" approach, I would have to admit.

.


IsaoShi ( ) posted Wed, 07 April 2010 at 7:12 AM

I'm at work sans Poser, but I can do some more debugging as soon as I get home this afternoon. I was just beginning to sort out the code last night, but I was running a bit low on concentration - too sleepy.

Quote - Is the ScriptsMenu folder somewhere different on mac?

Nope, it's exactly the same path to that folder.

Quote - that "should" be saying find the location of poser.exe or poserpro.exe and build a path adding Runtime:Python:poserScripts:ScriptsMenu

I didn't specifically check the results of this assignment, but I'm almost certain it's working correctly. The extra 'ScriptsMenu' level is being added to the path after building the menu tree, but before trying to execute the activated menu item. I'll track it down.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Wed, 07 April 2010 at 2:30 PM

Okay, I've taken a slightly different approach and I'm hoping that it is giving mac less problems.

http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu_Panel.zip

You don't need to remove any configuration files.  Those should be fine.

.


MarianneR ( ) posted Wed, 07 April 2010 at 2:44 PM

 When I try to run a python script with the second version I get this error message:

NULL (or empty) script name passed to PEPythonEngine:DoScript()


IsaoShi ( ) posted Wed, 07 April 2010 at 3:01 PM · edited Wed, 07 April 2010 at 3:03 PM

file_450822.png

The problem with the first script is with the GetPath(..) routine. It's doing an extra iteration that's adding the ScriptsMenu folder to the path which should not be there. Then it adds it again before returning the path to the EvtExec() routine. But I don't know Python and I'm not sure what this code is doing.

I'll try the new version now...

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Wed, 07 April 2010 at 3:04 PM

Okay, I think that mac is just not liking the idea of removing the .py or .pyc from the end of the path and then reconstructing it when trying to run a script.  More likely, it doesn't like the notion of how I'm doing it (syntax).

Give me a min to write a version closer to the original...

.


IsaoShi ( ) posted Wed, 07 April 2010 at 3:22 PM · edited Wed, 07 April 2010 at 3:23 PM

file_450824.png

Hmmm... this new version crashed Poser when I double-clicked a script. So I put a file check in place (as in the first version) to prevent it trying to run a non-existent script. That at least stopped it crashing!

And I added a debug print... you can see it's doing the same thing as before. It's the iterations in the GetPath() routine... for some reason this works differently on a Mac and it's doing an extra iteration. This is a little beyond my ken.

Edit: oops, I started my reply before testing, and ended up cross-posting, sorry.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Wed, 07 April 2010 at 3:29 PM

Sorry for the poser crash :/

Okay, I cleaned up a  part that might be causing confusion.  This still keeps the notion of hiding the .py or .pyc extension, which I think might be one issue.

http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu_Panel.zip

If the above doesn't work, here is a version that is closer to Dizzi's in that it is not going to hide the extension of the python scripts.  It is quickly zipped (there is no pathing in the zip file so you will have to place it manually):

http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu Panel mac.zip

.


Netherworks ( ) posted Wed, 07 April 2010 at 3:44 PM

Okay, the duplicate issue is a problem with the original script (I'm hoping):

self.Build(self.root, self.tree.AddRoot('ScriptsMenu')) in line 91

Once more, with feeling:

http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu_Panel.zip

.


IsaoShi ( ) posted Wed, 07 April 2010 at 3:58 PM

Bingo! Well done.
But why didn't it do the same on PC?

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Wed, 07 April 2010 at 4:13 PM

Quote - Bingo! Well done.
But why didn't it do the same on PC?

I don't know.  I can only guess that each OS is probably sensitive about different functions in their own way.

I changed that line to:

self.Build(self.root, self.tree.AddRoot(''))

and Windows is not having a problem with it either so I can only assume that its extraneous to even add a name to the root.  I'm working with XP here so I can only hope that there is no issue with Vista or 7 (hides in a corner)

Okay, for the other functions...

Can you define an editor using "Set Python Editor" in the script?  If so, will "Edit Script" allow you to open the script in that editor?

Also, I tried to include a routine for "Finder" as I understand that is the equivalent to Windows Explorer.  Do you get the option to "Browse with Finder" on a folder and does it work?

.


IsaoShi ( ) posted Wed, 07 April 2010 at 4:22 PM

file_450838.png

I was just testing the other stuff. Browse with Finder gives this error. Edit Script gives an almost identical error, which I'll post next.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


IsaoShi ( ) posted Wed, 07 April 2010 at 4:23 PM · edited Wed, 07 April 2010 at 4:24 PM

file_450839.png

Edit Script...

EDIT: hang on a couple, I'll debug print at those points...

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


IsaoShi ( ) posted Wed, 07 April 2010 at 4:39 PM

file_450845.png

I posted rubbish and deleted it... this is the Edit Script error message, with the path, which is correct. Must be something to do with the call to the editor?

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


nruddock ( ) posted Wed, 07 April 2010 at 5:58 PM

I think your problem is that the first argument to Popen really needs to be a list or tuple, i.e. a string is treated as just the program to run and isn't parsed like it would be if you typed it at the shell prompt.
Reference the examples in the 2.4 docs, section 6.8.3.4 "Replacing os.spawn*"


Netherworks ( ) posted Wed, 07 April 2010 at 7:13 PM

nruddock, thanks for your help.  I think something like this will work for the Edit command:

subprocess.Popen([path],executable=self.pyEditPath,shell=False)

'path' is the arguments (the file to open) and the self.pyEditPath is the path of the file editor executable.

.


IsaoShi ( ) posted Wed, 07 April 2010 at 7:21 PM

Traceback (most recent call last):

  File "/Applications/Poser Pro 2010/Runtime/Python/poserScripts/ScriptsMenu/ScriptsMenu Panel.py", line 227, in EvtMenu

    subprocess.Popen([path],executable=self.pyEditPath,shell=False)

  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 542, in init

    errread, errwrite)

  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 975, in _execute_child

    raise child_exception

OSError: [Errno 13] Permission denied

What do you mean, "Permission denied"?
Don't you know who I am, you pathetic little snake?
(Have to go to bed now).
 

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Wed, 07 April 2010 at 7:40 PM

LOL!

No worries and thanks for trying.

I'm going to have to raise the white flag on trying to get the mac to cooperate.  I just don't know what it wants and if there are any os specific issues on using subprocess.  I can get it to work using both the original way I wrote it and using arguments (which is probably the correct way) in Windows.

I can't seem to figure out how to get Browse with Explorer to work by using arguments.  Searches and code snippets are saying to use

subprocess.Popen('explorer '+path)

which is doing it without arguments.  I can't even fathom how to get finder to work if it isn't going to do it similarly.  I really hate to give up but it's obvious that things are working differently between the os'es even though this is more or less a universal platform.  We saw that happen a LOT with Tkinter, which still doesn't work properly between Windows and Mac across various versions of python.

Still, this is and will always be a freebie so if a mac python wizard wants to help make it work across both OSes, you have my blessing! :)

Until I can figure out what's going on, I can hide the menu entries for mac users so that there isn't any confusion or expectation.

.


nruddock ( ) posted Thu, 08 April 2010 at 3:03 AM

You haven't tried the form Popen([program, file])
What appears to be happening on Windows (and the example you mentioned seems to bear it out) is that a string is parsed, but on MacOS its treating it as the program (equivalent to putting quotes around the whole thing).

It also may be that you have to specify the full path to the program and/or specify use of a shell.
Check what works using a command prompt.


Netherworks ( ) posted Thu, 08 April 2010 at 2:01 PM · edited Thu, 08 April 2010 at 2:03 PM

Okay, that also works :)

Okay mac folks, does this test script work for you? (It should open the folder where your poser preferences reside):

# open directory test<br></br>
import poser<br></br>
import subprocess<br></br>
import os<br></br><br></br>
path = os.path.abspath(poser.PrefsLocation())<br></br>
subprocess.Popen(['finder',path])<br></br><br></br>

If I use 'explorer',path here it works on windows since explorer.exe is a running process.

.


MarianneR ( ) posted Thu, 08 April 2010 at 2:27 PM

 I put the script in the poserScripts folder and called it Testdir.py and this is what I got:

Traceback (most recent call last):

  File "/Applications/Poser Pro 2010/Runtime/Python/poserScripts/Testdir.py", line 7, in ?

    subprocess.Popen(['finder',path])

  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 542, in init

    errread, errwrite)

  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 975, in _execute_child

    raise child_exception

OSError: [Errno 2] No such file or directory


IsaoShi ( ) posted Thu, 08 April 2010 at 2:43 PM

file_450911.png

Same here. If I use the full path of the Finder.app in place of the text 'finder', it gives that permission denied message again. Does this suggest that Python is finding the Finder.app, but the OS is not allowing Python to execute it?

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


IsaoShi ( ) posted Thu, 08 April 2010 at 3:18 PM · edited Thu, 08 April 2010 at 3:23 PM

file_450914.jpg

This will open the folder in Finder:-

os.system('open "%s"' % path)

I tried this code in the ScriptsMenu script, and it works fine.

EDIT: note the single quotes outside the double quotes.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Thu, 08 April 2010 at 3:29 PM · edited Thu, 08 April 2010 at 3:30 PM

Okay, let's go back to Edit Script.  I updated the download again.  See if you can edit a script.

If not, we will try the syntax/command that you used for finder.

.


IsaoShi ( ) posted Thu, 08 April 2010 at 3:32 PM · edited Thu, 08 April 2010 at 3:34 PM

file_450915.jpg

On my system exactly the same code as above also opens the script for editing....

BUT

this is not a robust solution - it only works for me because in my OS I have chosen to open Python script files by default with TextEdit.

EDIT: cross-post.. I'll try the update.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Thu, 08 April 2010 at 3:38 PM

I've implemented your solution for the Finder/Explorer issue.

mac os will show "Browse with Finder" and use: os.system('open "%s"' % path)
windows os will show "Browse with Explorer" and use: subprocess.Popen(['explorer',path])

haven't updated the script, server-side, yet.

.


Netherworks ( ) posted Thu, 08 April 2010 at 3:41 PM

"this is not a robust solution - it only works for me because in my OS I have chosen to open Python script files by default with TextEdit."

Yeah, I have my system set to open .py files in Notepad++ by default :D

.


IsaoShi ( ) posted Thu, 08 April 2010 at 3:56 PM

Oh okay... on the version I just downloaded I was getting no 'Browse with Finder' option on the menu.

Edit Script is still giving me the Permission denied error message. I need some supper now, but afterwards I'll see if I can find the correct os.system() syntax for opening a file with a specified app, rather than just with the OS default app.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Thu, 08 April 2010 at 4:12 PM · edited Thu, 08 April 2010 at 4:13 PM

Yeah, I added the finder function back in just not in the current version.  It's set to go though once we figure out the editor issue.

I wonder if:

goMac = "start "+self.pyEditPath+"
%s"<br></br>
os.system(goMac % path)<br></br>

would do it?

I think the start command needs to be there for mac.

.


Netherworks ( ) posted Thu, 08 April 2010 at 4:23 PM

I have updated the download again.

In the script, lines 222 and 223 have the mac "Edit Script" code.

.


IsaoShi ( ) posted Thu, 08 April 2010 at 4:30 PM

Sorry, that code does nothing at all.
An error message is one thing, but being totally ignored is beyond the pale... :O)

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


Netherworks ( ) posted Thu, 08 April 2010 at 4:39 PM

Quote - Sorry, that code does nothing at all.
An error message is one thing, but being totally ignored is beyond the pale... :O)

Well, at least poser didn't crash :D

.


IsaoShi ( ) posted Thu, 08 April 2010 at 5:07 PM

Quote - Well, at least poser didn't crash :D

True. Unfortunately I must do just that. NIte!

PS: I have found nothing definite about how to open the script file for editing. Most forums recommend using subprocess rather than os.system, but I can't find any useful info about the permission problem we are getting.

"If I were a shadow, I know I wouldn't like to be half of what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki Murakami)


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.