Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
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.
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.
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?
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.
>>> 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)
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)
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.
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?