I do front panel graphics for electronics using Inkscape, and one part is quite painful. A circuit board, not the graphics, determines where knobs and components go. I then need Inkscape to center graphics to line up with the drill holes in a circuit board.
Here is an example...
First I make a circuit board with four knobs on it. Relative to the circuit board, the center coordinates of the knobs are (in inches):
(0.5, 3.3)
(1.34, 1.4)
(2.1, 0.75)
(3.4, 2.2)
Those numbers are made up, but the point is to show that I cannot just drop a grid into the Inkscape project and snap to that.
Second, I have a graphic to put around each knob to mark off specific angles. The problem is that X and Y coordinates of the graphic in Inkscape are not based on the center, but on the corner. So, I am not able to just put in the coordinates of where I want the graphic to move. Instead I have to modify the coordinates based on the size of the graphic. If I happen to have different graphics for each knob, the coordinates end up becoming something like this:
(0.5 - graphic_1_width/2, 3.3 - graphic_1_height/2)...
That involves doing a lot of hand calculation, which takes a lot of time and is error-prone. I have to do this operation hundreds of times so I use spreadsheets to manage it. I really hope there is a better way.
Basically, I just need to be able to take any graphic, and quickly tell it "move so that your center lines up with these specific x and y values."
How to move object to center around specific coordinates?
Re: How to move object to center around specific coordinates
I'm not aware of a way to directly set the x,y coordinates of the center of an object, but you might find that using guides makes your life a bit easier. In your example above, I would do the following:
1) Duplicate the basic outline of the circuit board
2) Object=>Objects to guide
3) For each guide, double click on it and edit the x,y coordinates by hand. Note that there's a "relative" checkbox which is what you would want in this case - it moves the guide relative to its current position, which as it was created from the board also implies relative to the circuit board.
4) Repeat these steps as needed to ensure that you've got an intersection of guides at the centre points you're interested in
5) Move your object into place with snapping enabled, and the "Snap nodes or handles", "Snap from and to centres of objects" and "Snap to guides" are selected
6) You should find that the centres of your objects snap to the intersections of the guides quite easily now.
Use the "|" keyboard shortcut to show/hide the guides to get a clearer view of what you're doing. Duplicate objects and convert them to guides to quickly create new guides at key reference points. Get familiar with the align and distribute dialogue - for aligning objects relative to already existing ones it's a faster option than using guides, but it doesn't offer you the ability to place things by numeric values.
1) Duplicate the basic outline of the circuit board
2) Object=>Objects to guide
3) For each guide, double click on it and edit the x,y coordinates by hand. Note that there's a "relative" checkbox which is what you would want in this case - it moves the guide relative to its current position, which as it was created from the board also implies relative to the circuit board.
4) Repeat these steps as needed to ensure that you've got an intersection of guides at the centre points you're interested in
5) Move your object into place with snapping enabled, and the "Snap nodes or handles", "Snap from and to centres of objects" and "Snap to guides" are selected
6) You should find that the centres of your objects snap to the intersections of the guides quite easily now.
Use the "|" keyboard shortcut to show/hide the guides to get a clearer view of what you're doing. Duplicate objects and convert them to guides to quickly create new guides at key reference points. Get familiar with the align and distribute dialogue - for aligning objects relative to already existing ones it's a faster option than using guides, but it doesn't offer you the ability to place things by numeric values.
Re: How to move object to center around specific coordinates
see here: viewtopic.php?f=5&t=9721&p=36105#p36105 for one method
You can also use the align and distribute dialogue. Select the circle you want to center on, select the larger object you want to place on top; then in the align and distribute dialogue (shift+ctrl+A) select Relative to->smallest object and then center both horizontally and vertically.
You can also use the align and distribute dialogue. Select the circle you want to center on, select the larger object you want to place on top; then in the align and distribute dialogue (shift+ctrl+A) select Relative to->smallest object and then center both horizontally and vertically.
Last edited by tomh on Fri Jul 08, 2011 8:21 am, edited 1 time in total.
Re: How to move object to center around specific coordinates
Welcome to InkscapeForum!
Those sound like reasonable solutions, from Xav and tomh. And I also agree that there is not an automatic way to accomplish this, short of creating some custom script or extension, or something.
I wanted to suggest snapping to centers of objects. You could take the graphic, enable snapping, snap nodes and handles, and snap to and from centers of objects; and then snap the center of the graphic to the point where the knob would be. That would cause the graphic to be centered around the knob. (Note that you might have to add a fill to the circle temporarily. If there's no fill, it might not snap. Then of course you can remove the fill before finishing the project.)
Would that work for you?
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Re: How to move object to center around specific coordinates
Thank you for the tips and the detailed explanation! Xav's solution ended up being a big improvement. I had never seen "guides" before. Giving a guide coordinates that are identical to component center coordinates on the circuit board makes something that I can snap the center of a graphic to. There is no more need for calculations.
Re: How to move object to center around specific coordinates
If you haven't seen guides before, you might not realise that as well as the "Object to guides" option I used above, you can also create them by click-dragging from the rulers into the Inkscape drawing area:
* Drag down from the top ruler to create a horizontal guide
* Drag right from the left ruler to create a vertical guide
* Drag at an angle from the top-left, top-right or bottom-left to create 45degree guides
With suitable snapping enabled the guides will snap to your existing objects, or you can double-click on a guide to set its coordinates via a dialogue.
* Drag down from the top ruler to create a horizontal guide
* Drag right from the left ruler to create a vertical guide
* Drag at an angle from the top-left, top-right or bottom-left to create 45degree guides
With suitable snapping enabled the guides will snap to your existing objects, or you can double-click on a guide to set its coordinates via a dialogue.
Re: How to move object to center around specific coordinates
This simple feature is really needed in inkscape. I also do a lot of panel labels and the ability to see the x,y centers of objects and move them are required.
I hope this is finished in a release soon. The work around methods are just to clunky.
I find myself using an old version of Corel Draw to speed up the process. I really like like so many cool features in inkscape, but this is a big one for the graphics user.
Look forward to next release, with an update for this..
Hoping can't hurt..
I hope this is finished in a release soon. The work around methods are just to clunky.
I find myself using an old version of Corel Draw to speed up the process. I really like like so many cool features in inkscape, but this is a big one for the graphics user.
Look forward to next release, with an update for this..
Hoping can't hurt..
Re: How to move object to center around specific coordinates
Well, this is pretty clunky too, and it will require some scripting external to inkscape. Look at the attached SVG file which contains 3 graphics objects and 3 associated text objects. You need to generate a file like that from your fixed positions. To do so you could use a general scripting program like python, or you could use a more specialized plotting tool like gnuplot or gle. Go the latter route if you don't want to reinvent the wheel. Set up a small gnuplot or gle script with (pseudocode):
draw x1 y1 object1 parameters
draw x2 y2 object2 parameters
...
and then render that to svg. Import the resulting svg into inkscape. For the initial checking of the plot you could render
to some other format (X11 or whatever) so that you can verify all of your input data is as you want. GLE has a semi-interactive mode specifically designed for letting you iterate between tweaking a script and redisplaying it. This would let you set up the framework of the diagram pretty quickly, while employing known coordinates, and then you could tweak other factors interactively in inkscape once the basics are done.
draw x1 y1 object1 parameters
draw x2 y2 object2 parameters
...
and then render that to svg. Import the resulting svg into inkscape. For the initial checking of the plot you could render
to some other format (X11 or whatever) so that you can verify all of your input data is as you want. GLE has a semi-interactive mode specifically designed for letting you iterate between tweaking a script and redisplaying it. This would let you set up the framework of the diagram pretty quickly, while employing known coordinates, and then you could tweak other factors interactively in inkscape once the basics are done.
- Attachments
-
- test.svg
- (3.32 KiB) Downloaded 248 times