Thu, Jan 30, 3:57 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: How to edit a model by selecting a frame in a script


Tekitoumen ( ) posted Wed, 20 July 2022 at 11:26 PM · edited Thu, 30 January 2025 at 3:42 PM

Hi.

I want to select a frame of a moving model (animation) and edit the model.

(For example, I want to give the model a walking animation and do something that makes the breathing rougher every frame)

It takes time to manually edit the model frame by frame.

Therefore, I want to automate it with a Python script.


1. Select the first frame

2. Select a chest

3. Edit the shape of the chest

4. Select the second frame

5. Select a chest

6. Select the shape of the chest

・・・repert


I want to know if the script can recognize the model frame by frame and edit the image.



scene.SetFrame(frame_num)

actors = scene.Actors()

actor = scene.Actor("Chest")

・・・


I repeated the following script and edited the model frame by frame but it didn't work.

The edited content given in the first frame was reflected in all frames.

If you know the right way, please let me know.


Thank you.


Y-Phil ( ) posted Thu, 21 July 2022 at 4:39 AM

Did you add key frames to your character?

𝒫𝒽𝓎𝓁


(っ◔◡◔)っ

👿 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, Sequoia 15.2, 16GB, 500GB SSD
👿 Nas 10TB
👿 Poser 13 and soon 14 ❤️


adp001 ( ) posted Thu, 21 July 2022 at 8:23 AM

Y-Phil posted at 4:39 AM Thu, 21 July 2022 - #4441630

Did you add key frames to your character?

I tried it with a fresh started P12 (Trial). Opened a Python Terminal and typed in:

poser.Scene().SetFrame(10)

Poser updated the framecounter as expected.

@Tekitoumen:

How do you try to change the current figure?

FYI:

fig = poser.Scene().CurrentFigure()

actor = fig.Actor("Chest")

geom = actor.Geometry()

geom.Vertices() (the base mesh) stays the same in every frame. It doesn't change. What changes is geom.WorldVertices(). It reflects what morphs, weightmaps etc did to modify the base mesh. But it makes no sense to change these values frame by frame. Better use morphs and activate/deactivate or set value to these morphs the way you need them at certain frames.




adp001 ( ) posted Thu, 21 July 2022 at 8:46 AM · edited Thu, 21 July 2022 at 8:46 AM

Example:

Assumed you have a figure with a morph called "Breath". To get a handle to that morph, do this:

figure = poser.Scene().CurrentFigure()
breath_morph = figure.Parameter("Breath")

Say you want to start with Breath == 0 at frame == 0 and a full breath (value=1) every 10 seconds. We further assume your scene goes with 25 frames per second. So, we have a full breath at 10 Seconds * 25 Frames == Frame 250, 500, 750, 1000, etc. 

full = True

for frame in range(0, poser.Scene().NumFrames(), 125):
    breath_morph.SetValue(int(full))
    full = not full

That's all it needs. Poser does the rest, interpolating all the steps in between.

To set a scene length that makes sense with those values, do something like:

poser.Scene().SetNumFrames(1000)




adp001 ( ) posted Thu, 21 July 2022 at 7:37 PM

ups! Forgot to set the frame:

for frame in range(0, poser.Scene().NumFrames(), 125):
    poser.Scene().SetFrame(frame)
    breath_morph.SetValue(int(full))
    full = not full




Tekitoumen ( ) posted Thu, 21 July 2022 at 10:29 PM · edited Thu, 21 July 2022 at 10:29 PM

Thank you for your response!

Thank you for your kindness.


I'm setting a keyframe.

Then select body parts (eg chest) for each frame and

I'm trying to select that vertex coordinate and edit the chest area as I like.

First I tried it with a simple script.(The chest is greatly deformed for easy understanding)

However, even if I edit only the 6th frame as shown below, all the frames will be edited in the same way when I look at Poser.

In this case, I want to edit only a specific frame (6th).

I haven't been able to edit frame by frame.


Is this a failed frame selection?

Or is it not possible to select and edit vertices for each frame?

Sorry for the lack of understanding of Poser.



MK1p9mV7bZC2pSEkoaeqU2UicOdT1q1xZGTHAvAB.PNG


GXnlP7qPuNUXOsWSaaPWBgEkyVoYzl88yrq8uqEW.PNG

---------------------------------------------------------------------------------------------------------------------------------------------------

import poser

import time

import os


x_axis = 0

y_axis = 1

z_axis = 2


scene = poser.Scene()


for test_num in range( 0, 6):

    actors = scene.CurrentFigure()

    scene.SetFrame(test_num)

    

    actor = scene.Actor("Chest")

    actGeom = actor.Geometry()

    #verts = actGeom.Vertices()

    verts = actGeom.WorldVertices()

    vert_num = actGeom.NumVertices()

    vert_list = [[0 for k in range(3) ] for j in range(vert_num)]


    #x,y,z vertices 

    list_num = 0

    while list_num < vert_num:

        vert = actGeom.Vertices()[list_num]

        Vx = vert.X()

        Vy = vert.Y()

        Vz = vert.Z()


        vert_list[list_num][x_axis] = Vx

        vert_list[list_num][y_axis] = Vy

        vert_list[list_num][z_axis] = Vz


        list_num = list_num + 1


    j = 0


    while j < vert_num:

        if test_num == 5:

            set_z.SetZ(vert_list[j][z_axis] - 0.5)

---------------------------------------------------------------------------------------------------------------------------------------------------

Thank you.


Tekitoumen ( ) posted Tue, 26 July 2022 at 10:14 PM

I'm sorry. My understanding was not enough.


Thanks to you guys, I found the following.

・ The coordinates of the model cannot be changed for each frame.

・ If you create a morph first, you can set it for each frame.


Thank you.


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.