Python method to add a Runtime folder to library?



  • One for the pythonists.
    Sweet and simple:
    Is there a scriptable way to manage the list of Runtime folders known in the Poser library?


  • Poser Ambassadors

    Agreed!! I would like to change the order of my rundtimes ... even create an outline format for different runtimes in categories.



  • @boni & @fverbaas the LibraryPrefs.xml file contains an XML formatted list of the library folders and lives in PrefsLocation().

    It's contents look like:

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- LibraryPreferences.				 -->
    <!-- Created: Tue Dec 19 02:27:10 2017			 -->
    <LibraryPreferences curFolder="0"  version="1"  previewNum="100"  limitPreview="0"  doubleClickReplace="0" >
    	<ContentFolder folder="/Users/Shared/Poser 11 Content/Runtime/libraries"  index="0"  searchIndexed="1" />
    	<ContentFolder folder="/Users/Shared/Poser 11 Content/Downloads/Runtime/libraries"  index="1"  searchIndexed="1" />
    	<CollectionFolder folder="Runtime/libraries/Collections"  index="0" />
    	<ContentFolder folder="/Volumes/HiggsBosonHD/Poser Content/Poser Pro Content/Victoria 4/Runtime/libraries"  index="2"  searchIndexed="1" />
    	<ContentFolder folder="/Volumes/HiggsBosonHD/Poser Content/Poser Pro 2014 Content/Runtime/libraries"  index="3"  searchIndexed="1" />
    ...
    </LibraryPreferences>
    

    So it seems reasonable that an XML parser could manipulate the 'index="<number>"' entries to reorder the list. The only thing I can't guarantee is what would be required to cause the library to re-read it's preferences, other than a Poser restart.

    poser.Libraries() seems to return an index ordered list of the library folder paths from this file, but there's no method to do anything with a list the user has manipulated.

    I couldn't see anything in the Poser Python manual to allow modification of the library directly, such as adding a new runtime. I've been looking for a way to force the library to update after a script has created new content, but it doesn't seem possible at the moment. Very frustrating.


  • Poser Ambassadors

    Other than the fact I don't do python ... I have gotten a similar response before when I've asked this question. This would be a great feature in future versions of Poser. Being able to control the order and structure of the library runtimes.



  • @boni well, being an XML file, you could just edit it in a text editor (taking care to preserve the structure), or a dedicated XML editor, and change the order and index values by hand, save the file (keeping a backup in case of typo) and restarting Poser, no Python needed for that task.


  • Poser Ambassadors

    The index numbers in the XML attribute mean nothing. I do not know at all why they are there. The order of the lines matters - not what is claimed in the index.

    So you can literally just edit the file, moving the lines around, and it works.

    A script could also edit the file but Poser has to be restarted to activate the new list no matter how it is edited.

    Don't edit it while poser is running. It might rewrite it on exit.



  • @bagginsbill that's a useful distinction to make. Appearance order follows file order. I wonder if the index relates to the other Library related XML file, LibraryState.xml in some way.

    Though, of course, it could simply be an initial data design that became redundant during implementation, or else a way to preserve discovery order of the folders, even if the line order governing appearance is shuffled. Perhaps it's to do with entry order in the search index database, so removing a folder doesn't immediately break the search indexing of later folders.

    All completely academic speculations unless somebody bothers to change the values and discover that something breaks, or the person that wrote the code trawls the depths of their memories and can be arsed to tell users why it was done that way.



  • OK Thank you all.
    Yes, you can edit the file and take out/bring in extra lines when Poser is not running. I did that a few times to clean up or move a Runtime I recently added to the top of the list.

    I had silently hoped that BB could point to some secret back door.
    OK. We have to live with
    Thank you again.



  • @bagginsbill said in Python method to add a Runtime folder to library?:

    The index numbers in the XML attribute mean nothing. I do not know at all why they are there. The order of the lines matters - not what is claimed in the index.

    Does this have anything to do with why the library, the Scripts menu, and various other parts of Poser no longer list items in alphabetical order on my Mac? I can't remember now if that happened when I upgraded to Poser Pro 11.1 or to macOS High Sierra (10.13), but it's been that way for a while now.

    The output of some Python scripts is also no longer presented in alphabetical order, most notably the output of Netherworks' Mister Lister, which I use to prepare the files list for freebie readme files.

    (If this isn't at all related to the OP's original question, my apologies!)



  • On another slightly tangential note: after trying various ways of using multiple runtimes, I finally came up with a structure that works very well for me and that does not require me to fiddle with XML files in order to do things like change order.

    I now use only three runtimes: (1) Poser 11 Library; (2) My Poser Library (for all items made by others); and (3) My CUSTOM Library (for all items made by me). I've extensively customized both 2 and 3 using the Mac's Finder, which is the primary way I search, navigate, and organize libraries and their folders, so that I can easily find what I need without resorting to using separate runtimes.

    For example, I created the same set of "top level" folders in the Characters, Pose, Hands, and Face libraries for the items I use most often (V4, M4, K4, Horses, Various Critters, Various Humanoids, Various Robots). And everything in each of those top level folders is further organized in a way that makes the most sense to me, such as having sub-folders for apparel items like shoes, pants/skirts, outfits, etc.

    So my first tip is that you can organize items within a runtime's Library however you'd like. My second tip is that you don't have to keep a library's associated file type files in that library.

    For example, I put all materials for clothing in the Materials library, regardless of whether it's in PZ2 or MC6/MT5 format. And I put all PP2 dynamic clothes as well as PP2 props that go with clothing items in the Character library, since that's where I expect to find all of a figure's clothing.

    The only thing I use the Props library for is actual props that are independent of any figure, and I have that one organized by type of prop (Sci-Fi, Nature, Houses, Outer Structures, Chambers, Roads+Trails, and so on). I put everything associated with each prop into its folder inside the Props library, including lights, cameras, and material files. And it all works just fine!

    It definitely took some time to get everything organized in a truly useful way, but it was SO worth it b/c now I know exactly where to find things. (I also used the macOS's Finder to tag items by figure, style, etc., so I can see, for example, all my dresses at a glance, but that's a different topic!)



  • @perpetualrevision are you using APFS volumes under macOS High Sierra? Apparently the low level routines for APFS volumes return file results in on-disk on-SSD order, and leave explicit sorting to higher level routines. Any code which previously relied on sorted behaviour from OS file routines will have to now explicitly sort results.


  • Poser Ambassadors

    @perpetualrevision said in Python method to add a Runtime folder to library?:

    Does this have anything to do with why the library, the Scripts menu, and various other parts of Poser no longer list items in alphabetical order on my Mac?

    Nope.

    The OS used to return lists of files in order so applications written for Mac don't sort them because that would be dumb. This has changed.

    https://discussions.apple.com/thread/8178786


  • Poser Ambassadors

    @anomalaus said in Python method to add a Runtime folder to library?:

    @perpetualrevision are you using APFS volumes under macOS High Sierra? Apparently the low level routines for APFS volumes return file results in on-disk on-SSD order, and leave explicit sorting to higher level routines. Any code which previously relied on sorted behaviour from OS file routines will have to now explicitly sort results.

    This



  • @anomalaus said in Python method to add a Runtime folder to library?:

    and leave explicit sorting to higher level routines. Any code which previously relied on sorted behaviour from OS file routines will have to now explicitly sort results.

    Thanks to you and BB for the replies. So it looks like I'll have to wait for Poser 12 for alphabetical sorting to return, provided they include the code to explicitly sort results!



  • @perpetualrevision well, the devs do seem to like their sorting! To the extreme I'm struggling with now, where hidden joint and visible deformerPropChan parameters seem to have their order reversed and their evaluation order changed every time they're loaded or saved. It's driving me absolutely nuts, since I have some clothing figures either slaved or conformed to V4 which need to have the V4 deformers also operate on them. It works perfectly when I first load the figures from the library into a scene, but breaks every time I have to reload the saved scene (stupidly often, due to Poser crashes). I also need the evaluation order preserved since deformers after morphs actually works differently now, whereas before, I assume it made no difference. The order has to match exactly for base figure and tight, conformed clothing, otherwise there's pokethrough, but it only appears when a scene is reloaded.


  • Poser Ambassadors

    @perpetualrevision said in Python method to add a Runtime folder to library?:

    @anomalaus said in Python method to add a Runtime folder to library?:

    and leave explicit sorting to higher level routines. Any code which previously relied on sorted behaviour from OS file routines will have to now explicitly sort results.

    Thanks to you and BB for the replies. So it looks like I'll have to wait for Poser 12 for alphabetical sorting to return, provided they include the code to explicitly sort results!

    You can try to set LIB_ITEMS_SERVER_SORT to 1 in Poser.ini.
    It is a setting which makes Poser sort the list when it retrieves a file list from the OS.
    In my case the list was unsorted when the library retrieved a file list from a network drive on a NAS. This poser.ini setting makes Poser sort that list first.



  • Runtime Rodent from Netherworks?