Align origin to centre of region/group

I’ve imported a drawing of cogs from inkscape to synfig. I want to animate them rotating, however I’ve noticed that origin is set to the centre of the canvas, which means that when I rotate them they’re rotating off-centre.

Peek 2021-01-27 20-51

To get them rotating about their centre I’d need to put the origin into the exact centre, as illustrated below:

Screenshot from 2021-01-27 21-09-32

I can move the origin to the centre but moving it manually isn’t accurate and they’re still off-centre by a bit.

Peek 2021-01-27 20-52

Is there a way to automatically align the origin to the centre of the region/group?

image While creating circles just keep this property checked.

That option only appears when creating objects in Synfig, not on objects imported from svg files.

I’ve included an updated version of the example file. As specified in the original post I want the origin of each object to be in the exact centre of each object. I tried importing into Synfig via the import menu and by saving it as an .sif file from Inkscape and got the same result each time.

cogs

Using the Origin parameter and setting it value to reflect the coordinates found in Inkskape?
Or using a Group layer and/or Translate Layer?

I tried your suggestions on both synfig 1.4.0 and I compiled it myself a couple of days ago.

The first issue is that synfig’s coordinates system has 0,0 in the centre of the screen (with no way to change it) and Inkscape’s 0,0 is either top left or bottom left. So I had to do a bit of maths to convert them. For the top-left cog the centre is approximately located at -288.5px, 277.5px

Clicking on the cog region layer itself and changing the origin coordinates will change it but it’ll move the cog as well. I can’t move just the origin and not have it move the cog. I can highlight the cog’s node and attempt to move them manually but this isn’t accurate.

Peek 2021-01-28 21-15

I put the cog region layer into a group and it immediately made the origin go to the centre of the screen.

Screenshot from 2021-01-28 21-20-17

The group layer has an offset node I can move and attempt to get it into the middle of the cog but, again, this is inaccurate, and given how many decimal places are in the parameter editor getting the value to exactly -288.5, 277.5 just by clicking and dragging will be near impossible!

Still on the group layer if I try entering those values manually it moves the cog. I tried entering the values directly into the Origin and Offset parameters and both times it moved the the cog.

I tried your final suggestion of using a Translate layer and changing the origin parameter either by clicking and dragging or entering it manually just resulting the the cog moving.

Unless I’m missing something really obvious I can’t see a way to get the origin of an imported shape to its centre accurately.

If someone knows how to do this and is able to do a screen recording I’d really appreciate it!

As a work around, I’ll suggest you use grids and grid snap features.

Here’s a solution for finding the centre of an object which uses inkscape in combination with synfig. I will be using this vector file.

cogs

If you’ve already prepared your scene in another program e.g. inkscape this becomes easier. If not then you’re on your own! Make sure you have your units in Synfig set to px (probably can be done using synfig’s units but I’m not going to work that out).

In inkscape turn on “Snapping centres of bounding boxes”. Draw guides on the x and y axis and snap them to the centre of the object. Double-click on the guide and it’ll tell you the x/y position of the centre of the object (332.296,332.708px).

Screenshot from 2021-01-29 16-25-25

Write this down somewhere, but also note that inkscape’s 0,0 point is at the top-left of the screen. Now save it as an .sif file from Inkscape.

In Synfig first put your cog in a group layer. We can’t type in new origin values without it moving the whole group so we’ll use guides, enable snapping to guides, and then move the origin handle the grid point.

Synfig’s 0,0 point is at the centre of the screen, so we need convert the x/y placement of the guides in inkscape to match the coordinates system of Synfig. I don’t know if there’s an automated way of doing this so I did it manually by drawing guides in Inkscape to get the centre of the document and measuring the distance from them to the cog’s centre.

The updated guide positions for Synfig are at -119.38x200.08px. However, even though my units in Synfig are set to px the guides are still set to be in units. See here for more details: https://wiki.synfig.org/Canvas_MetaData_Panel . 1 unit = (image width in pixels)/(image area width) (see here for more details https://wiki.synfig.org/Unit_System). The document is 903x1065 and has an image area from -7.52689 - 7.52689, so 1 unit is 903/15.05378 = 59.984934017 .

With that info we can find out where to place our guides! The x guide should be at 200.08/59.984934017 = 3.334666667 and the y guide at -119.381÷59.984934017 = -1.989683333.

With the guides now showing where the middle of the cog is I should be able to drag the origin offset handle (the light purple handle) to the guides and it’ll snap to them. Well, yes and no. The origin offset handle itself will snap to the guides but of course the one we want to snap is the position handle itself (the green one). However if it is moved the whole group, objects and all, are moved.

Screenshot from 2021-01-29 17-43-16

I remember that in earlier versions of synfig I could hold Ctrl and click on the position handle to move it but I think the offset handle/light purple dot has replaced it(?).

So, I can now use this quite long method to get the centre of an object. I’d just have to repeat this for every object that I wanted to find the centre of…

Here’s my file if you want to try yourself

cogs_compressed.sifz (121.7 KB)

1 Like

Of course this solution doesn’t scale well at all. I’ve read the relevant documentation and ave tried lots of different things but it just seems this isn’t possible. Really happy to be proven wrong. Post a tutorial if you can!

In the meantime I’ve created a bug report here https://github.com/synfig/synfig/issues/2005 . This align & distribute report also seems very relevant https://github.com/synfig/synfig/issues/1704