Sketcher ToggleActiveConstraint

From FreeCAD Documentation
Revision as of 21:54, 29 February 2024 by FBXL5 (talk | contribs) (several ways added)

Sketcher ToggleActiveConstraint

Menu location
Sketch → Sketcher constraints → Activate/deactivate constraint
Workbenches
Sketcher
Default shortcut
K Z
Introduced in version
0.19
See also
Sketcher Toggle driving/reference constraint

Description

The Sketcher ToggleActiveConstraint tool allows you to activate and deactivate an already placed constraint. This allows you to keep the constraint in the background but temporarily test another arrangement of the existing geometry.

The Sketcher ToggleDrivingConstraint tool is similar in that it disables the effect of the constraint; however, with this tool, the constraint does not keep its old value. On the other hand, with Sketcher ToggleActiveConstraint you can re-activate the old constraint immediately.

Usage

  1. Select one or more existing constraints.
  2. There are several ways to invoke the command:
    • Press the Activate/deactivate constraint button.
    • Select the Sketch → Sketcher constraints → Activate/deactivate constraint option from the menu.
    • introduced in version 0.22: Right-click in the 3D view and select the Activate/deactivate constraint option from the context menu.
    • In the Constraints section of the Task panel select the Activate or Deactivate option from the context menu. (The option depends on the cursor position: over an active constraint it is Deaktivate and over a deactivated one it is Activate respektively)
    • Use the keyboard shortcut: K then Z.
  3. Active selected constraints are deactivated and turn grey while deactivated selected constraints are activated and return to red.

Examples

Fully constrained sketch.

Left: deactivated constraint; the sketch is no longer fully constrained. Right: the unconstrained geometry can be moved around; the older constraint is still available, and can be re-activated to return to the fully constrained sketch.

Task panel with the deactivated constraint.

Scripting

See also: FreeCAD Scripting Basics.

The active status of a constraint can be controlled in macros and from the Python console.

SketchObject.toggleActive(index)

Use the toggleActive method of an existing Sketcher SketchObject, and the index of the constraint to activate it or deactivate it. The index starts from 0 all the way to N-1, where N is the total number of constraints.

Example:

import FreeCAD as App

sketch = App.ActiveDocument.Sketch
sketch.toggleActive(3)