Skip to main content

2 posts tagged with "sketcher"

View All Tags

· 4 min read
Brad Collette
Alexandre Prokoudine

We’ve already introduced some improvements to sketching with constraints before, when Pierre-Louis Boyer implemented contextual constraints. But there are more usability gaps there, and we are targeting them one by one. There’s another major change currently undergoing code review: on-viewport tool widgets to create fully constrained sketches and tool settings to set various properties and choose drafting behavior.

Drafting fully constrained sketches

Thanks to Ondsel’s developer Pierre-Louis Boyer and FreeCAD maintainer Abdullah Tahiriyo, the Sketcher workbench is now getting UX/UI improvements that aim to improve drafting fully constrained sketches. Pierre-Louis shot a quick video for internal use that we are sharing with you.

Here is a quick explainer of what’s coming in version 1.0 here.

The usual workflow for creating a sketch is drawing shapes, then constraining them. That takes quite a while, if you intend to fully constrain a shape. Let’s say we draw just a line. To fully constrain it, we then have to:

  • Select its start and constrain its distance to X and Y coordinate origins (for XY plane)
  • Select the line and constrain its distance
  • Add another constrain to define its angle to X (for XY plane)

Of course, there are several more ways to fully constrain a line, but the general idea is the same: draw a line in roughly the right spot, then “fix” it.

If we are drawing more complex shapes (e.g. polygons), getting them fully constrained takes even more time and effort, though contextual constraints help with that somewhat. Can we speed it up? Yes, that’s the point of this coming improvement.

Now when you select a shape-drawing tool and hover the viewport, FreeCAD will display numeric entry widgets right in the viewport. When you type in a new value and press the Tab key, FreeCAD applies a constraint, updates the shape in the viewport, and moves the focus to the next entry widget. This is how it works for a line:

Currently supported objects are points, lines, rectangles, circles, and polygons. It’s possible to add support for more object types.

Tool settings

The second user-visible part of the patch is introducing tool settings in the Tasks panel. This helps build more expressive tools.

Different ways to define a shape will now be easily accessible: e.g. a line can be defined by the position of two points or by a combination of the start point’s coordinates, the length of the line, and the angle.

Another possibility is different shape styles. A rectangle with rounded corners can now be an option of the regular rectangle tool. Similarly, rectangles can have a frame around them with user-defined thickness.

Finally, you can use it to set an inherent property of a shape, such as the amount of sides in a polygon.

The same can be applied to arcs and conics later on.

Further work

This is still an early implementation undergoing review, so there will be both minor tweaks and new features further down the road. Here are some of the ideas we have:

  • Enabling expressions in the spinboxes
  • Adding Rotate, Scale, Translate tools with on-viewport widgets
  • Adding a Chamfer tool to Sketcher

Another thing we are planning to do is make full constraining an optional feature for users who want to be able to decide how many degrees of freedom they need for each particular shape. This could be a global preference setting or a quick toggle in the toolbar when you need to mix both approaches in the same project.

We are looking forward to reading your feedback. Until the patch has been merged, the best place to provide it is the pull request.

· 3 min read
Brad Collette
Alexandre Prokoudine

One of the hallmark features of FreeCAD is that various parts of its UI have a lot of similar options, which means a lot of cognitive load, especially for beginners. A very popular “offender” here is the geometry constraints toolbar in Sketcher. It has 18 different constraint options, more than most popular commercial CAD offerings like Fusion 360, Onshape, and Creo. That's not a bad thing on its own, but it adds a lot of mileage when you need to dimension an entire complex sketch.

Constraint options in FreeCAD 0.21

Before joining Ondsel, Pierre-Louis Boyer (@paddle) started implementing a feature called contextual constraints to help users constrain faster. Since joining Ondsel, he has finished the patch, and after some discussion and code review it was merged to become part of future FreeCAD 1.0. This new feature is quite nice and surpasses what many commercial CAD applicaitons are able to do. So let’s take it for a drive and kick the tires!

When you select a geometric feature in a sketch, there’s a finite number of constraints you apply once you select the second feature. For example, if you select a line and then an endpoint of another line, your most meaningful option is a distance constraint. But if you select a line and then another line that’s at an angle to the first one, the angle constraint is the most meaningful option, and your other option is to make those lines equal.

Once you know that, you can devise a system that looks at the selected features, suggests the most sensible option by default, and allows switching between possible options easily. This is what the new contextual constraints system does. It helps apply constraints based on the context of what the user has already done. You select the new Dimension option (D shortcut) and go over your entire sketch to constraint and dimension various parts of it.

The new option combines various pre-existing other ones: constraining distances, radii, diameters, angles, and a constraint lock.

Here is a quick example. Take two lines that have different length and are at a random angle and distance to each other:

Original state

Then select the Dimension option and set the length of the first line:

Length constraint

Set a distance between the two lines by clicking the line and then the closer endpoint of the second line:

Distance constraint

Constraint their angle by clicking the first line and the second line:

Angle constraining

And finally make both lines equal by clicking the first line and the second line and then pressing M to switch to the second contextual constraint option:

Equal length lines

You can constrain this sketch further by clicking on an end point of one of the lines and setting a lock, all with the same Dimension option. Most importantly, all of the steps above are completed without needing to choose a different tool in the toolbar.

For cases, when you absolutely need to have quick access to individual constraint options (just like in v0.21 and earlier), you can continue using keyboard shortcuts or selecting those options in the drop-down list:

Individual options

Preserving that possibility was one of the requests from users.

The new option also allows switching between complementary angles depending on the position of the mouse:

Switching between complementary angles

This implementation was possible thanks to active discussions both on the forum and in the issue tracker. More improvement is still possible. Join us if you want to be part of making FreeCAD awesome and many thanks to users and contributors for their input!