Feature Request: Geometric Construction Tool (Constraints and constraint solver) for CAD, CAM etc.
Steps to reproduce:
- open Inkscape
What happened?
very limited options to create accurate technical drawings
What should have happened?
As an engineer, I'm using Inkscape a lot to create drawings for laser-cutting. However, there are very few options to create accurate technical drawings, especially a "sketch mode" with a constraint solver is missing. This feature has been on the wish list for a long time and some work has been done in this direction, but there is no current Issue in the Inbox tracking this feature, although it is requested rather often even outside of Launchpad.
History
From my research, the very first mention of CAD features was this issue in 2006, which evolved into an entire subgroup of features - CAD import (wiki page), 3D capabilities (extrusion, wiki page) and constraint solving. This issue focuses on the latter.
A part of constraint solving had already been requested before: "gluing" nodes together (i.e. a coincidence constraint, see this issue from 2005). This issue also outlines more advantages to constraint solving than just technical drawings, it could also be used to create educational mathematics demonstrations.
This features was requested again in 2008 and subsequently became a project for the GSoC in 2008 by Maximilian Albert. He suggested an extensive list of features in this wiki page and a way to implement this - Live Paths Effects.
From what I can reconstruct, Maximilian wrote a proposal, it was accepted and he started to work on this feature. From what I was able to find, at least the following features and constraints were implemented:
- circle-with-cadius, perpendicular-bisector and tangent-to-curve status update
- add on-canvas handles for LPEs in a semi-automatic fashion
- circle through 3 points, angle bisector, parallel to a line (it only uses start and end point of the path), rotate copies (similar to tiled clones), offset (in progress, see next email) status update
- Each LPE can now display custom helper paths
Current situation
These features were apparently compiled into a "Geometric Construction tool", but left out for the 0.47 release. It can be activated for custom compiled versions though (#73), but lacks some of the features that Maximilian wrote about (https://vimeo.com/14955725).
Instead, some features were implemented as standalone LPEs:
- mirror (uses on canvas handles for the symmetry axis)
- corner (fillet/chamfer)
- Ellipse by 5 points
- measure segments (it's mentioned in the original wiki article, but technically out of scope).
Some of the other features are available as "experimental" LPEs (Angle bisector, circle by center and radius, parallel, perpendicular bisector, tangent to curve)
Still, there have been some bugfixes lately regarding the Geometric Construction tool.
What is really needed?
These LPEs are super helpful, but are not what are really needed for CAD-like sketching. To elaborate on this, one needs to understand that the workflow of an engineer in CAD is highly different from the workflow of a designer in a graphics program. As an engineer, I would normally do this:
- sketch up a rough first version of the sketch, using lines, arcs, rectangles, maybe some bezier curves. Ideally, during drawing, there is a "snap to constraint" feature, i.e. a "vertical" constraint is automatically added when drawing a vertical line, and analogously for constraints like "parallel", "point on path", "tangent", "perpendicular", "symmetric", "equal length", "equal angle" - but not absolute lengths or angles. In most CAD programs, these "auto-constraints" can be temporarily disabled by pressing a modifier key.
- add the remaining constraints and especially dimensioning constraints, until the sketch is fully constrained. These might be relative to other constraints (e.g. "this path has 2x the length of this other path")
- Now I might notice that I'd like to change one of the sketched features. I'll delete the feature, features dependent on this via constraints must not be deleted, but made underconstrained. When I've replaced the feature, I add the remaining constraints to make the sketch fully constrained again.
- Fully constrained means that there is nothing left that can be moved with the mouse. You don't move nodes in a technical drawing to change the shape, you change the constraints. That's the only way to make sure that everything is designed exactly as intended.
And that's why I doubt LPEs are the right way forward. LPEs display/create new objects (e.g. the "symmetry" or "circle through points" LPE), they don't constrain existing objects and they certainly don't move around referenced paths. While it's possible to create cyclic graphs out of LPEs, it's not conventient and breaks as soon as an element is to be deleted. (Caveat: I don't know the code base; so maybe LPEs have some magic features that are just not used at the moment).
List of features
Adding a fully-featured constraint solver to Inkscape would be a unique feature for a vector design program, but super helpful in engineering and creation of scientific drawings, but also general designing workflows.
The following is an incomplete list of features that such a "Constraint" tool should have (might add more later):
- At least the following constraints should be made available:
- Coincident (Point on point, Point on path, line segment on line segment)
- Distance (Distance to page border, point-to-point, point-to-line (perpendicular))
- Dimension (projected length, segment length, radius, angle). Distance and Dimension can depend on other constraints (i.e. an "equality" constraint).
- Horizontal / Vertical segment
- Concentric circles
- Symmetry (axial symmetry, point symmetry)
- Parallel, perpendicular
- Tangent
- In "Auto-Constraint" mode, constraints are added automatically when creating new paths (for an incomplete list, see first bullet point in the previous paragraph).
- Constraints can be added manually between the right type of elements - especially the standard SVG shapes like circles, rectangles, ...
- All constraints can be modified in the drawing region, not with some obscure toolbox requiring tons of extra clicks
- Results from some shape tools (star, polygon, rectangle), LPEs (symmetry, rotated copies) and alignment tools (equal distance) could be converted to constraints automatically. Imagine: you sketch a line, copy it 10 times, distribute them equally, which is stored as "equality" constraint. If you want to increase the distance now, you only have to move one line and the others follow, maintaining the distance.
- When the constraint tool is active, all constraints are visible. When it's inactive, constraints that impede an object's movement are displayed. Likewise, a fully constrained node can not be moved with the mouse.
- If a constrained sketch is copied, the constraints are copied along. If objects A and B are linked with constraint C, in the copied sketch constraint C' links objects A' and B'.
- Special attention should be given to underconstrained sketches, which will be highly common when this feature is implemented in Inkscape. Since underconstrained systems have an infinite number of solutions per definition, the constraint solver will need some restrictions to output the most "intuitive" solution.
- Constraints are saved in the SVG file, but not displayed in a browser.
- A constrained sketch can be exported to and imported from CAD programs.
Keep in mind that constraint solving is a non-trivial subject. There are entire mathematical books on it and a huge amount of papers available. Apparently, 2geom already has some constraint solving features, at least the project page says so, but I have no idea how advanced they are and if they have ever been used in production.
Inkscape Version and Operating System:
- Inkscape Version: any
- Operating System: any
PS: If this is the wrong place to discuss this, feel free to remove it. I just tried to collect some information on the idea, the current progress and a way to implement this. If bugs were still reported on Launchpad, this issue would probably be closed as a duplicate. Since we're asked to migrate bugs, I thought a summary would be appropriate for all the separate bugs requesting this.
Edit history: 2019-12-29: added copying of constrained sketch to list of features