Sat, Dec 21, 8:06 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 Dec 02 3:16 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: What changes are needed to get this to work in Poser 12+ ?


3dcheapskate ( ) posted Fri, 12 January 2024 at 1:45 AM · edited Thu, 19 December 2024 at 11:00 AM

This is  a simple crappy cobbled together Poser 11 Python 2 script, one of four, from something I'm playing with over on the HiveWire3D forum here, post #66 - Towards better grass in Poser... | Page 4 | HiveWire 3D Community - and I'd like to get it working in Poser 12+ Python 3 too

1) Since I only have Poser 11 I can't test any changes I make to it

2) I don't really want to import compatibility libraries if I can do it without.

3) I know that I need to include brackets in my print "stuff" statements, thusly print ( "stuff" ) to get them to workin both Python 2 and 3

4) The try...except version stuff can go - that's a bit I forgot to delete from the source scrpt that I bashed about

5) Ideally I want one script that works in both Poser 11 and Poser 12+


P.S. Don't forget to put on your peril-sensitive sunglasses before looking at the 'code' ;o)


# RandomizeHexGeometries.py (Prototype 0.00)

# Test script for adding Ajax Easypose style ERC to a figure.


# 0.00: 



import poser,random


# I put my scripts into a class simply to avoid possible conflict with stuff in the __main__ module.

class cheapskatesTemporaryClass(object):

def main(self):

# Get Poser version for doing version-specific stuff

poserversion = '0'

posermainversion = '0'

try:

self.poserversion = poser.AppVersion()

temp = self.poserversion.split('.')

self.posermainversion = temp[0]

except:

pass

# Abort if the user gets cold feet right at the start

confirmed = poser.DialogSimple.YesNo("This script randomizes hex geometries.\n\nDo you wish to continue?")

if not confirmed:

confirmed = poser.DialogSimple.YesNo("Do you want to see more information about what this script does?\n\n(This opens a debug window with extra information and terminates the script. You'll probably need to resize the debug window to read the information.)")

if confirmed:

# Briefly explain to the user what this script does and give an option toabort straight away

print "This script randomizes hex geometries... MORE EXPLANATION TO GO HERE"

return

# Abort if no figure selected

scn = poser.Scene()

curfig = scn.CurrentFigure()

curact = scn.CurrentActor()

if not curfig:

poser.DialogSimple.MessageBox("You need to have a figure selected for this script to do anything.\n\nScript aborted, no changes made.")

return

# Abort if the currently selected actor is NOT part of the figure (parented props are NOT part of the figure)

if not(curact.IsBodyPart() and curact.ItsFigure().Name()==curfig.Name()):

poser.DialogSimple.MessageBox("The selected actor is not an integral part of the selected figure.\n\nScript aborted, no changes made.")

return

# Let user select random grass or bump geometries

confirm1=poser.DialogSimple.YesNo("Set random geometry for each hex?")

if confirm1:

fromgrass = 1

tograss = 10

grassMenu = ["All grass (01-10)","Just old grass (01-05)","Just new grass (06-10)"]

sel = poser.DialogSimple.AskMenu('Subset only ?','Select subset range:',grassMenu)

if sel == grassMenu[0]:

fromgrass = 1

tograss = 5

elif sel == grassMenu[1]:

fromgrass = 1

tograss = 5

elif sel == grassMenu[2]:

fromgrass = 6

tograss = 10

# Reset the master geometry variant in the body

act = curfig.ActorByInternalName("BODY")

act.Parameter("Geometry Variant").SetValue(0)

print "Master geometry variant reset to 0"

# Randomize the geometry variants for each bone

i = 1

while i < 38:

if i < 10:

bone = "subhex0" + str(i)

else:

bone = "subhex" + str(i)

randgeom = random.randint(fromgrass,tograss)

print bone + " geometry set to " + str(randgeom)

act = curfig.ActorByInternalName(bone)

act.Parameter(bone+"_variants").SetValue(randgeom)

i = i + 1

# Redraw what we've modified

scn.Draw()

# Inform the user that it's all done

poser.DialogSimple.MessageBox("All done")

poser.DialogSimple.MessageBox("Running 3DCheapskates RandomizeHexGeometries.py script (prototype 0.00)\n\n(N.B. You should see a similar message when the script finishes. If you don't then the script has crashed!)")

cheapskatesTemporaryInstance = cheapskatesTemporaryClass()

cheapskatesTemporaryInstance.main()

poser.DialogSimple.MessageBox("3DCheapskates RandomizeHexGeometries.py script (prototype 0.00) all done.")



Footnote: code above cut-and-pasted from NotePad++ after changing EOLs to just LF. Also attempting to add RandomizeHexGeometries.txt to this post below




The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).



RAMWorks ( ) posted Fri, 12 January 2024 at 9:06 AM

Watching... 

---Wolff On The Prowl---

My Store is HERE

My Freebies are HERE  


3dcheapskate ( ) posted Sat, 13 January 2024 at 5:40 AM

...and hoping ? ;o)


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).



Y-Phil ( ) posted Sun, 14 January 2024 at 2:39 PM

I had to add two "try: except:" blocs, probably because I didn't used your script the right way, but as is, it works with Poser11 and Poser13
The key is the very first line, and indeed the use of print(...) even with Poser11.

from __future__ import print_function

# RandomizeHexGeometries.py (Prototype 0.00)
# Test script for adding Ajax Easypose style ERC to a figure.
# 0.00:

import poser,random


# I put my scripts into a class simply to avoid possible conflict with stuff in the __main__ module.

class cheapskatesTemporaryClass(object):
    def main(self):
        # Get Poser version for doing version-specific stuff
        poserversion = '0'
        posermainversion = '0'
        try:
            self.poserversion = poser.AppVersion()
            temp = self.poserversion.split('.')
            self.posermainversion = temp[0]
        except:
            pass

        # Abort if the user gets cold feet right at the start
        confirmed = poser.DialogSimple.YesNo("This script randomizes hex geometries.\n\nDo you wish to continue?")
        if not confirmed:
            confirmed = poser.DialogSimple.YesNo("Do you want to see more information about what this script does?\n\n(This opens a debug window with extra information and terminates the script. You'll probably need to resize the debug window to read the information.)")
            if confirmed:
                # Briefly explain to the user what this script does and give an option toabort straight away
                print("This script randomizes hex geometries... MORE EXPLANATION TO GO HERE")
            return

        # Abort if no figure selected
        scn = poser.Scene()
        curfig = scn.CurrentFigure()
        curact = scn.CurrentActor()
        if not curfig:
            poser.DialogSimple.MessageBox("You need to have a figure selected for this script to do anything.\n\nScript aborted, no changes made.")
            return

        # Abort if the currently selected actor is NOT part of the figure (parented props are NOT part of the figure)
        if not(curact.IsBodyPart() and curact.ItsFigure().Name()==curfig.Name()):
            poser.DialogSimple.MessageBox("The selected actor is not an integral part of the selected figure.\n\nScript aborted, no changes made.")
            return


        # Let user select random grass or bump geometries
        confirm1=poser.DialogSimple.YesNo("Set random geometry for each hex?")
        if confirm1:
            fromgrass = 1
            tograss = 10
            grassMenu = ["All grass (01-10)","Just old grass (01-05)","Just new grass (06-10)"]
            sel = poser.DialogSimple.AskMenu('Subset only ?','Select subset range:',grassMenu)
            if sel == grassMenu[0]:
                fromgrass = 1
                tograss = 5
            elif sel == grassMenu[1]:
                fromgrass = 1
                tograss = 5
            elif sel == grassMenu[2]:
                fromgrass = 6
                tograss = 10

            # Reset the master geometry variant in the body
            try:
                act = curfig.ActorByInternalName("BODY")
                act.Parameter("Geometry Variant").SetValue(0)
            except:
                pass
            print("Master geometry variant reset to 0")

            # Randomize the geometry variants for each bone
            i = 1
            while i < 38:
                if i < 10:
                    bone = "subhex0" + str(i)
                else:
                    bone = "subhex" + str(i)
                randgeom = random.randint(fromgrass,tograss)
                print(bone + " geometry set to " + str(randgeom))
                try:
                    act = curfig.ActorByInternalName(bone)
                    act.Parameter(bone+"_variants").SetValue(randgeom)
                except:
                    pass
                i = i + 1

        # Redraw what we've modified    
        scn.Draw()

        # Inform the user that it's all done
        poser.DialogSimple.MessageBox("All done")

poser.DialogSimple.MessageBox("Running 3DCheapskates RandomizeHexGeometries.py script (prototype 0.00)\n\n(N.B. You should see a similar message when the script finishes. If you don't then the script has crashed!)")
cheapskatesTemporaryInstance = cheapskatesTemporaryClass()
cheapskatesTemporaryInstance.main()

poser.DialogSimple.MessageBox("3DCheapskates RandomizeHexGeometries.py script (prototype 0.00) all done.")

𝒫𝒽𝓎𝓁


(っ◔◡◔)っ

👿 Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
👿 Mac Mini M2, Sonoma 14.6.1, 16GB, 500GB SSD
👿 Nas 10TB
👿 Poser 13 and soon 14 ❤️


Y-Phil ( ) posted Sun, 14 January 2024 at 2:41 PM

Oh and just in case: I'm using Microsoft's Visual Studio Code, a free version exists for mac and linux as well, a simple copy-paste in the pages here does the trick.

𝒫𝒽𝓎𝓁


(っ◔◡◔)っ

👿 Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
👿 Mac Mini M2, Sonoma 14.6.1, 16GB, 500GB SSD
👿 Nas 10TB
👿 Poser 13 and soon 14 ❤️


3dcheapskate ( ) posted Mon, 15 January 2024 at 6:22 AM · edited Mon, 15 January 2024 at 6:23 AM

Y-Phil posted at 2:39 PM Sun, 14 January 2024 - #4480368

I had to add two "try: except:" blocs, probably because I didn't used your script the right way, but as is, it works with Poser11 and Poser13
The key is the very first line, and indeed the use of print(...) even with Poser11.

from __future__ import print_function

...(clipped)...

poser.DialogSimple.MessageBox("3DCheapskates RandomizeHexGeometries.py script (prototype 0.00) all done.")

Thanks, works fine in Poser 11 just as you said. 

I'm curious about one thing though - to get my Freazypose to work in Poser 12 the only thing I had to do was add brackets to the prints - I didn't need to import the __future__ module. See ADPs two responses following my observation here. I'm fairly sure it's the same situation here.


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).



3dcheapskate ( ) posted Mon, 15 January 2024 at 6:32 AM · edited Mon, 15 January 2024 at 6:32 AM

Y-Phil posted at 2:41 PM Sun, 14 January 2024 - #4480369

Oh and just in case: I'm using Microsoft's Visual Studio Code, a free version exists for mac and linux as well, a simple copy-paste in the pages here does the trick.

What EOL character does it use ? I recall having to use some bizarre EOL workaround to get cut-and-paste from NotePad++ to these forums to work. (And the alternative of attaching a text file still doesn't work)

I find that Notepad++ is more than sufficient for all my needs - the less MS stuff I have on my laptop the better, although I grudgingly permit Windows 10 :o)


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).



3dcheapskate ( ) posted Mon, 15 January 2024 at 7:03 AM

Uploaded an updated set of the four scripts to post #77 of the HiveWire3D topic. Trying without importing the __future__ module, which after reading ADPs comments I don't think is necessary - these scripts are really simple. Also deleted the unnecessary Poser version try...except.


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).



Y-Phil ( ) posted Mon, 15 January 2024 at 9:20 AM

Ok, great bxC0Ak112ApXhHnluGpqZxrYgriNQ8AkTBfYVYNw.png

𝒫𝒽𝓎𝓁


(っ◔◡◔)っ

👿 Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
👿 Mac Mini M2, Sonoma 14.6.1, 16GB, 500GB SSD
👿 Nas 10TB
👿 Poser 13 and soon 14 ❤️


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.