Sat, Nov 9, 10:44 PM CST

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: OBJ Export Script Scaling


PickledPapaya ( ) posted Tue, 25 September 2012 at 4:05 PM · edited Sat, 09 November 2024 at 10:28 PM

I was trying to put together a Python script to export the scene as an OBJ and scale it up, so that it imports into Blender in a more blenderish size.

This is my cutup of the imp/exp script in Render control. (Poser 9)

There is a code called: kExOptCodeSCALEFACTOR - Scale exported scene by this amount.

I have modified it to 1, 10, and 100 with no difference in the exported size?

Any thoughts?

#---------------------------------
# Exporting an OBJ scaled up for Blender 
# WaveFront .obj file format
#---------------------------------

#---------------------------------
# Get the scene and the Import-Export object
#---------------------------------
currentScene = poser.Scene()
imExObject = currentScene.ImExporter()


print ""
print "Setting OBJ Export Options..."
exoptions = imExObject.ExportOptions("obj", None)
#for key in exoptions.keys():
#       print key, ':', imExObject.ExportOptionString("obj", None, key), '=', exoptions[key]



#---------------------------------
#  Set some known standard OBJ Export Options...
#---------------------------------
exoptions[poser.kExOptCodeUSEINTERNALNAMES] = 0
exoptions[poser.kExOptCodeFIRSTFRAME] = 0
exoptions[poser.kExOptCodeLASTFRAME] = 29
exoptions[poser.kExOptCodeMULTIFRAME] = 0
exoptions[poser.kExOptCodeWELDSEAMS] = 1
exoptions[poser.kExOptCodeASMORPHTARGET] = 0
exoptions[poser.kExOptCodeBODYPARTNAMESINPOLYGROUPS] = 0
exoptions[poser.kExOptCodeFIGNAMESINGROUPS] = 1
exoptions[poser.kExOptCodeEXISTINGGROUPSINPOLYGROUPS] = 0
exoptions[poser.kExOptCodeSCALEFACTOR] = 100

print "Exporting in Wavefront .obj format..."
try:
        #---------------------------------
        # export it
        #---------------------------------
        imExObject.Export("obj", "File Format Wavefront", "C:TEMPyooowza.obj", exoptions)

        print "Export succeeded"

except:
        print "Export failed -- please check the file name"


RobynsVeil ( ) posted Tue, 25 September 2012 at 9:51 PM

Don't know if this has anything to do with anything but those values after the options appear to correspond to constants stored in some Poser Dictionary. Not sure if I'm reading it right...

"The PoserPython options dictionary now includes enumerations of import and export options.  These options correspond to UI option strings present in dialog boxes when importing/exporting files from within Poser using the normal interface.  For users who need access to the strings as they appear in the dialog boxes, you can query the strings by passing the enumeration constant into the ImportOptionString() and ExportOptionString() methods (discussed below).
Codes such as poser.kExOptCodeMULTIFRAME are pre-defined constants with unique identifying values.  For instance:

poser.kImOptCodeCENTERED = 0
poser.kImOptCodePLACEONFLOOR = 1
poser.kImOptCodePERCENTFIGSIZE = 2
poser.kImOptCodeOFFSETX = 3
poser.kImOptCodeOFFSETY = 4

The values 0 to 4 do not represent the values or choices the options are set to, but rather, they are simply codes uniquely identifying each option.  It is unlikely that you will ever need to know or set them.  A more typical use of import/export option enumeration values is illustrated in the following line of code:

options[poser.kExOptCodeFIRSTFRAME] = 2

The above example sets the value of the FirstFrame option to 2.

Monterey/Mint21.x/Win10 - Blender3.x - PP11.3(cm) - Musescore3.6.2

Wir sind gewohnt, daß die Menschen verhöhnen was sie nicht verstehen
[it is clear that humans have contempt for that which they do not understand] 

Metaphor of Chooks


markschum ( ) posted Tue, 25 September 2012 at 11:26 PM

have a look at your scale factor again. The only one I remember for Export is to do with scaling in BVH exports.

 

I use Lightwave so I load the item and scale it up if I want to model at real world scales. Then export it scaled smaller.   In 3dsmax the importer allows you to scale. I dont know blender.


PickledPapaya ( ) posted Wed, 26 September 2012 at 8:12 AM

Yea, I did not see a Import Scale option in Blender either, so I seemed to be stuck either way, doing it manually.  Was just trying to get it automated.  It's not that big of a deal, I guess

Thanks for the replies


PickledPapaya ( ) posted Wed, 26 September 2012 at 12:18 PM · edited Wed, 26 September 2012 at 12:19 PM

Yea, I did not see a Import Scale option in Blender either (they have a Clamp Scale option, but it does not seem to change anything related to the scale of the OBJ being imported?), so I seemed to be stuck either way, doing it manually.  Was just trying to get it automated.  It's not that big of a deal, I guess

Thanks for the replies

(whoops double post)


markschum ( ) posted Wed, 26 September 2012 at 3:03 PM

Just a thought but have you tried the blender forum ?


PickledPapaya ( ) posted Wed, 26 September 2012 at 4:06 PM

Yep, I am waiting to hear back on BlenderArtists.org  :tongue1:


PickledPapaya ( ) posted Wed, 26 September 2012 at 4:10 PM

...and they replied and I may need to upgrade to a later Blender.


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.