odf opened this issue on Aug 20, 2009 · 49 posts
odf posted Sat, 19 September 2009 at 12:35 AM
So, one of the things I'm working on is to specify content by selection patterns. For example, with the current version of the library, you can say something like
Document.fromFile("xx.cr2").extract("actor",
"channels", "scale.*", "keys",
"k").write("zz.pz2")
and that will grab all the scale settings for actors from the figure file xx.cr2 and write them into a pose file named zz.pz2.
Or you could say
val doc =
Document.fromFile("xx.cr2")<br></br>
doc.root.delete("actor head:.*", "channels",
"targetGeom", "indices|numbDeltas|deltas")<br></br>
doc.write("zz.cr2")
to clear all the deltas from the head actor and write the modified figure to a new file zz.cr2
The arguments of the extract and delete methods are selection patterns that each specify a list of lines or sections in the Poser file. So for examples, if the first argument says "actor", it looks for all actor sections and continues the search within those. Then if the second argument says "channels", it looks for channels sections within the actor ones, and so forth. The API is still in the process of materializing, which is why it would be great to have some more request on what the library should be able to do easily (hint, hint).
One thing I'm wondering about the best syntax for those patterns. At the moment, I'm using a sequence of arguments, each of which is a regular expression, plus some special syntax for negation and arbitrary "in between" paths. For example, extract("actor", "channels", "groups", "", "!groupNode") would pick up anything within a dial groups section that is not a group node. The "" stands for "anything in between" and the "!" stands for "does not match".
I wonder if something closer to Unix-like file paths with wildcards would be useful. Then instead of extract("actor",
"channels", "scale.*", "keys",
"k")
, one could say extract("actor/channels/scale*/keys/k")
. This might feel more familiar to most people than regular expressions. I'd still need some not so familiar syntax on top of that, but that's also true if I go with regular expression.
Any input would be much appreciated.
-- I'm not mad at you, just Westphalian.