Fri, Nov 22, 6:10 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: A query with materials


Anthony Appleyard ( ) posted Tue, 27 November 2018 at 7:21 AM · edited Fri, 22 November 2024 at 5:57 PM

If fig is a figure, and act is a jointed part of fig:

figmats=fig.Materials(); # gets fig's materials

actmats=act.Materials(); # gets act's materials.

But act.Materials() gets the materials which are declared in the actor (which can happen if the actor has its own geometry), and also the materials of the figure that act is a part of.

As a result, in a Python script that searches through the materials in a scene, each of a figure's materials is handled once in looking at the figure, and again when looking at each of that figure's actors. How can I prevent that unnecessary rehandling? How can I get a list of ONLY an actor's own materials?


FVerbaas ( ) posted Fri, 30 November 2018 at 12:42 AM
Forum Coordinator

Maybe just not call skip searching the fig.Materials? I do not know for sure but fig.Materials() may well loop over the actors in the scene, filter out the actors that are part of fig, and report the materials.

Shorter may be to loop over the figures to get the condensed list there, and in the actors loop skip those that are not body parts.


ironsoul ( ) posted Fri, 30 November 2018 at 12:56 AM

I've always worked on the assumption they return pointers to the same information and the figure methods are there to avoid having to search the whole scene when working on a character. In the past I've just called the scene.actors() and used the IsXXX() functions to filter out unwanted object types before processing the mats. Maybe my assumption is wrong but the scripts seem to work ok.



Anthony Appleyard ( ) posted Fri, 30 November 2018 at 2:41 AM · edited Fri, 30 November 2018 at 2:42 AM

figmats=fig.Materials(); # lists only the big list of materials at the end of the figure's section in the ,cr2 or.pz3 file.

actmats=act.Materials(); # does the same, but includes in the list any materials which are declared in that actor's description, as can happen e.g. if that actor is a replace-body-part-by-prop.

Poser Python has operators and functions to make intersections and sums of lists; how can I compactly get a list of all items which are in list X but not in list Y?


FVerbaas ( ) posted Fri, 30 November 2018 at 1:57 PM
Forum Coordinator

From the top of my head:

inXbutnotinY = list() for mat in matsX: if not (mat in matsY): inXbutnotinY.append(mat)

not tested; no guarantees.


FVerbaas ( ) posted Fri, 30 November 2018 at 2:51 PM
Forum Coordinator

Grr they messed up the formattting:

inXbutnotinY = list()
   for mat in matsX:
      if not (mat in matsY):
         inXbutnotinY.append(mat)


ironsoul ( ) posted Fri, 30 November 2018 at 5:22 PM

Anthony Appleyard posted at 11:02PM Fri, 30 November 2018 - #4340855

figmats=fig.Materials(); # lists only the big list of materials at the end of the figure's section in the ,cr2 or.pz3 file.

actmats=act.Materials(); # does the same, but includes in the list any materials which are declared in that actor's description, as can happen e.g. if that actor is a replace-body-part-by-prop.

Poser Python has operators and functions to make intersections and sums of lists; how can I compactly get a list of all items which are in list X but not in list Y?

Thanks for the explanation. Assume the example you gave is also known as geometry swapping - didn't realise that also included the material too.



bagginsbill ( ) posted Sat, 15 December 2018 at 11:50 AM
>>> a = [1, 2, 3, 4, 5]
>>> f = [1, 2, 3]
>>> [e for e in a if e not in f]
[4, 5]


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Sat, 15 December 2018 at 11:51 AM

also:

>>> set(a) - set(f)
set([4, 5])


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Sat, 15 December 2018 at 11:54 AM · edited Sat, 15 December 2018 at 11:54 AM

I would point out there are quite a few more things to say about computing the difference between two lists, and your concern for order, performance, and memory may factor into a more general discussion. In which case, googling is probably faster and more informative than asking here. For example:

https://stackoverflow.com/questions/3462143/get-difference-between-two-lists


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


ironsoul ( ) posted Sun, 16 December 2018 at 5:38 PM

When I tried set functions on Poser list they just came back empty. One thought was that Poser list members are not unique so can't be converted.



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.