[PD] Edit Pd file to change coordinates. pdlua or other language?

Daniel Iglesia daniel.iglesia at gmail.com
Sat Mar 19 21:52:43 CET 2016


I'd guess it probably _is_ doable in Pd, with some tangled use of the
[text] (using "search" and "set").
When I do this type of manipulation, it's for mobile, so I'm limited to
Objective-C and Java, but if you use Java you could adapt Chris' parser:

https://github.com/chr15m/PdDroidParty/blob/master/src/cx/mccormick/pddroidparty/PdParser.java

to get a java data structure representation. Or, potentially simpler, port
the parsing logic in that file to python or whatever language you want to
use.


On Sat, Mar 19, 2016 at 12:36 PM, João Pais <jmmmpais at gmail.com> wrote:

> Dear list,
>
> I wanted to edit some Pd files so that I can change the coordinates of
> *some* lines. For example, if in a pd file there is the content:
>
> #N struct 1164-element float x float y float nr float index float nr-show
> float tick-show;
> #N canvas 168 80 670 664 gui 0;
> #X obj 186 548 textfile;
> #X obj 167 328 openpanel;
> #X obj 395 878 delay;
> #X obj 474 838 expr 60*$f1/$f2*1000;
> #X msg 166 668 stop;
> #X obj 293 207 hradio 17 1 0 6 \$0-instructions \$0-colord-i empty
> 0 -6 0 8 -134268 -1 -1 0;
>
> I wanted:
> a) in the lines beginning with "#X obj", to change the 2 fields afterwards
> to a general value I'll give in the command (e.g. all lines are changed "#X
> obj 100 100 ...")
>
> b) to exclude from this operation the line numbers I supply, preferably in
> an expression such as "5 10 20-30" etc.
>
> To give an example, with the command "100 100 4-6", the text above would
> be changed to
>
> #N struct 1164-element float x float y float nr float index float nr-show
> float tick-show;
> #N canvas 168 80 670 664 gui 0;
> #X obj 186 548 textfile;
> #X obj 167 328 openpanel;
> #X obj 395 878 delay;
> #X obj 100 100 expr 60*$f1/$f2*1000;
> #X msg 166 668 stop;
> #X obj 100 100 hradio 17 1 0 6 \$0-instructions \$0-colord-i empty
> 0 -6 0 8 -134268 -1 -1 0;
>
> where all lines starting with #X obj were change, except for lines 4-6.
> Further numbers or ranges after 4-6 would indicate other lines to exclude
> from the replacement.
>
> I know this isn't a task which can be done in Pd, but much better in a
> language such as lua or python. As I don't know any of these languages, I
> would appreciate some guidance on how to start, and maybe I could myself
> continue the work. Preferably I would like to try it in lua, so that I
> could process it in pdlua. But any suggestions are welcome. Except using
> grep, as I only have access to an ms-dos console, no bash or similar ones.
>
> Thanks,
>
> jmmmp
>
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20160319/c05138bc/attachment.html>


More information about the Pd-list mailing list