Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
I tried to run this on Mac OS, from terminal, python 2.3.5 and got this error: Traceback (most recent call last): File "/Users/pciccone/FixHexMT.py", line 42, in ? FILEIN1_FN = sys.arv[1] AttributeError: 'module' object has no attribute 'arv' I don 't know Python but all the other C-like languages I know use 'argv' instead of 'arv' so I tried to change it and it worked without errors except that when I try to load the MT in Morph Loader, for D|S, the plugin loads the file but says that there was no effect for the morph target. Any idea?
Paolo
https://www.preta3d.com
FB: https://www.facebook.com/RealityPlugIn
Tw: @preta3d
G+:
https://plus.google.com/106625816153304163119
The
Reality Gallery: https://reality-plug-in.deviantart.com
Your right it's a typo.
Fixed script attached.
Thank you nruddock.
By the way, I got this error running on Poser6(J).
Traceback (most recent call last):
File "", line 38, in ?
NameError: name 'False' is not define
To avoid this error, I added 2 lines to source codes.
(sorry, I'm not python programmer)
....(cut)....
import sys
import os.path
True=1 <----add
False=0 <----add
try:
import poser
isPoser = True
....(cut)....
Quote - Output: "Number of vertices read is 0" -- which makes me wonder if the Hex obj export for Mac is what is screwy. Quick edit: actually... maybe not. There are 'v' lines in the Hex exported obj.
There should also be lines that start as follows printed out :-
File size ...
Number of lines ...
If your not seeing those then the fix isn't kicking in, so replace the following lines
if (os.name == 'mac'):
lines = filein2.read()
lineSource = lines.split()
print "File size", len(lines)
print "Number of lines", len(lineSource)
else:
lineSource = filein2
with
# if (os.name == 'mac'):
lines = filein2.read()
lineSource = lines.split()
print "File size", len(lines)
print "Number of lines", len(lineSource)
# else:
# lineSource = filein2
This should tell me at least something about what's happening.
I suspect that I'll need you to send me something exported from Hex (a cube would do), so that I can examine it.
Object uploaded and link in sitemail. grin I ended up getting the same message in terminal, however. I'm pretty sure I edited the script properly, but there's always the chance I didn't and can't tell, so you may want someone less code stupid than I am to double check also.
-D
---
It's all fun and games until someone loses an eye texture.
Quote - for me it does´t work :( Just beginning to hate my mac, running Tiger 10.4
If your referring to the last script posted, then I'm pretty much out of ideas as to how to fix it for Macs.
Are you getting an error message, or is it still just not processing the vertices properly ?
As a last resort, if you have D|S, then you could use the version I did for that.
Total newbee to python...But I think the reference to os.name='mac' is for classic or Os9. for 10.+ or OSX I think it is 'posix'. I was messing around with some file path routines trying other peoples code and it didn't work until...A. printed the os,name and discovered it is 'posix'. B. edited the lines where required from 'mac' to 'posix' and it worked almost as expected. Granted total newwbee, so I could be 100 percent wrong. I no longer have a classic cpu to test this on as my newest machine is the intel chopped mac which can't run classic.
When I mean worked almost as expected...
Plus in early messing around, posix directory builds seem to me to like some variable + '/'+ filename vs what appears to be the wintel method of '' Again keep in mind I know about as much as you could put on the end of a pin head in regards to python.
If you use the '' method it appears it saves the file with a file name that is the entire file path runtimepsesomesubdirectorypose01.pz2 vs putting it where it is suppose to be with just the pose01.pz2 as the true and target file name.
Gary
"Those who lose themselves in a passion lose less than those who lose their passion"
Quote - Total newbee to python...But I think the reference to os.name='mac' is for classic or Os9. for 10.+ or OSX I think it is 'posix'.
That would certainly explain part of the problem.
I know it's something I could sort out quickly if only I had access to a Mac.
I've been careful with the filename handling, there aren't, AFAICT, any OS specific operations in the original script.
Quote - > Quote - > Quote - Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.
You have to remove the ending .doc! The correct ending is .py
Thankz I'll try that :D Then I just put it in my Poser python folder or what?
That´s the correct way! In Poser then you have to open the window "python-scripts" klick a empty button and then navigate to the script, so you can run it!
Quote - > Quote - > Quote - > Quote - Umm sorry can someone give me a brief explanation of how to use this? It just wants to open with my Word software.
You have to remove the ending .doc! The correct ending is .py
Thankz I'll try that :D Then I just put it in my Poser python folder or what?
That´s the correct way! In Poser then you have to open the window "python-scripts" klick a empty button and then navigate to the script, so you can run it!
I must sound like a total idiot but I don't generally use Python scripts of any kind. I changed the file to a .py and loaded into Poser 5. When how do I use it? I tried to use it on a piece of clothing and I got an error message something about line 54? Then I can't select my python window, only to close it. Am I doing it all wrong?
Quote - I must sound like a total idiot but I don't generally use Python scripts of any kind. I changed the file to a .py and loaded into Poser 5. When how do I use it? I tried to use it on a piece of clothing and I got an error message something about line 54? Then I can't select my python window, only to close it. Am I doing it all wrong?
Poser 5 doesn't have the DialogFileChooser method, so you'll need to edit the filenames into the script, or use it from the command line with a standalone Python install.
Quote - > Quote - I must sound like a total idiot but I don't generally use Python scripts of any kind. I changed the file to a .py and loaded into Poser 5. When how do I use it? I tried to use it on a piece of clothing and I got an error message something about line 54? Then I can't select my python window, only to close it. Am I doing it all wrong?
Poser 5 doesn't have the DialogFileChooser method, so you'll need to edit the filenames into the script, or use it from the command line with a standalone Python install.
So it would work in Poser 6/7 but not in P5 then? How do I run it from the command line with a standalone Python install? Or for that matter edit the filenames into the script?
You need to rename the saved file so the extension is .py - delete the .doc extension basically (The forum software won't allow you to upload .py files directly)
My Freebies
Buy stuff on RedBubble
Quote - You need to rename the saved file so the extension is .py - delete the .doc extension basically (The forum software won't allow you to upload .py files directly)
Thank you! I did get the correct .py file, and I have gotten it to work correctly in Poser since my last post. It seems for Poser 5 that you have to write the file names into the .py for each body part, anyway that's how it works for me. I really luv that it fixes this problem. Thankz again!
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.
It is for single group morphs only.
To use for FBM work, you must be using a figure turned into a single group, and using UVmapper to save and replace the grouping.
Does not preserve normals, UV coordinates, or materials (which is why UVmapper is needed).
Can be run using either from the command line using a standalone python :-
python FixHexMT.py original.obj morph.obj fixed.obj
The script can be edited to supply the file paths.
All paths must be specified on the command line or in the script (i.e. the script supplied values do not act as defaults for missing command line arguments).
Can be run from Poser, in which case if all of the paths are not supplied by the script (i.e. one or more is blank) then FileChooser dialogs are used to collect the required filenames.
Discussions and bugs in this thread please.