Duplicating a canvas


#1

I’m just getting started with Synfig, and I’m beginning to work out a personal strategy for using it. I think a strategy based largely on the keyframe-saving and recalling method described in the extremely eye-opening (ha.) “Reuse Animations” tutorial would be an efficient way of animating in the style I’m going for. However, many elements of my rigs are repeated and should have the same sets of poses, such as legs and eyes. I want to be able to add each pose only once while creating a rig, then import that rig into a scene, duplicate the canvases of the elements in question, assign each element one of the duplicated canvases, and animate them independently using the same sets of predefined keyframes. Is there any way for me to do this?


#2
  1. On the “library” of objects (those you have in the hard disc and want to reuse) DO NOT have anything exported. If there are exported the exported value nodes or canvases will be linked to the file on the hard disk once opened in Synfig Studio, what is bad for reusability. If you need exported value nodes then create them once you have incorporated the stuff on your new animation.
  2. Just open the “library” files and copy paste the stuff. That’s the best way to incorporate (reusing) things on a new document, without keep links from anywhere.

We need a way to “clone” objects from files with all its exported value nodes. It could be natively through a Synfig Studio menu action or a by a external script.
-G


#3

That sounded easy enough, so I went ahead and made a Python script to do it. Here it is on Pastebin. I don’t think it can be used as a plug-in, since it takes arguments.
I’m currently sick and having trouble thinking straight, so it’s barely-tested, uncommented, slightly messy, and doesn’t handle errors at all. I’ll probably come back and clean it up when I’m feeling better. And maybe move it somewhere better than Pastebin. I figured I might as well show you what I’ve got, though.
It takes two arguments: a source canvas and a destination canvas. They’re referenced in the same way they are in .sif files, i.e. “filename#:chain:of:child:canvases”. If the filename is left out in the destination, it’s assumed to be in the same file as the source. If everything but the filename is left out in the source, it uses the root canvas from that file. I don’t know if that has any dire implications or whatever, I just felt like adding it as a feature.
The destination canvas will be created and cloned from the source canvas. If it already exists, it will be merged with what’s there, which is interesting and probably a terrible idea. All “use” attributes will be handled pretty much correctly, as far as I know. Ones that aren’t contained within the source canvas will get one of those external XML links with a pound sign. It supports .sif, .sifz, and .sfg.

Anticipated but untested problems:
Existing references to files will break if the source and destination are in different directories.
Newly-created references to files (the ones I mentioned earlier for the “use” attributes) will break if the files aren’t specified on the command-line in just the right way.

So, there’s my script. Yippee.


#4

nice

… i did’nt test … but will move your thread in scripting …


#5

Great! Will sure be useful!