Sketcher ToggleActiveConstraint: Difference between revisions

From FreeCAD Documentation
(→‎Scripting: Example:)
(Marked this version for translation)
(26 intermediate revisions by 5 users not shown)
Line 2: Line 2:
<translate>
<translate>


<!--T:1-->
{{Docnav
{{Docnav
|[[Sketcher_ToggleDrivingConstraint|Toggle driving/reference constraint]]
|[[Sketcher_ConstrainInternalAlignment|Internal Alignment]]
|[[Sketcher_SelectElementsWithDoFs|Select solver DOFs]]
|[[Sketcher_SelectElementsWithDoFs|Select unconstrained DoF]]
|[[Sketcher_Workbench|Sketcher]]
|[[Sketcher_Workbench|Sketcher]]
|IconL=Sketcher_ToggleDrivingConstraint.svg
|IconL=Constraint_InternalAlignment.png
|IconR=Sketcher_SelectElementsWithDoFs.svg
|IconC=Workbench_Sketcher.svg
|IconC=Workbench_Sketcher.svg
|IconR=Sketcher SelectElementsWithDoFs.svg
}}
}}


<!--T:2-->
{{GuiCommand
{{GuiCommand
|Name=Sketcher ToggleActiveConstraint
|Name=Sketcher ToggleActiveConstraint
|Workbenches=[[Sketcher_Workbench|Sketcher]]
|Workbenches=[[Sketcher_Workbench|Sketcher]]
|MenuLocation=Sketch → Sketcher constraints → Toggle activate/deactivate constraint
|MenuLocation=Sketch → Sketcher constraints → Activate/deactivate constraint
|Shortcut={{KEY|K}} {{KEY|Z}}
|SeeAlso=[[Sketcher_ToggleDrivingConstraint|Toggle driving constraints]]
|Version=0.19
|Version=0.19
|SeeAlso=[[Sketcher_ToggleDrivingConstraint|Sketcher ToggleDrivingConstraint]]
}}
}}


==Description==
==Description== <!--T:3-->


<!--T:4-->
[[Sketcher_ToggleActiveConstraint|ToggleActiveConstraint]] 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 [[Image:Sketcher_ToggleActiveConstraint.svg|24px]] [[Sketcher_ToggleActiveConstraint|Sketcher ToggleActiveConstraint]] tool activates or deactivates selected constraints. Deactivating constraints allows you to test other geometry arrangements without deleting constraints.


<!--T:5-->
The {{Button|[[File:Sketcher_ToggleDrivingConstraint.svg|16px]] [[Sketcher_ToggleDrivingConstraint|Toggle driving constraint]]}} 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 {{Button|[[File:Sketcher_ToggleActiveConstraint.svg|16px]] [[Sketcher_ToggleActiveConstraint|ToggleActiveConstraint]]}} you can re-activate the old constraint immediately.
This is tool is similar to [[Sketcher_ToggleDrivingConstraint|Sketcher ToggleDrivingConstraint]], but contrary to that tool also works for geometric constraints, and values of deactivated dimensional constraints are preserved.


== Usage ==
== Usage == <!--T:6-->


<!--T:7-->
# Select an already placed constraint, then press {{Button|[[File:Sketcher_ToggleActiveConstraint.svg|16px]] [[Sketcher_ToggleActiveConstraint|ToggleActiveConstraint]]}}.
# Select one or more constraints.
# Alternatively, got to the [[task_panel|task panel]], to the {{MenuCommand|Constraints}} section, select the constraint, then open the context menu (right-click), and select {{MenuCommand|Deactivate}}.
# There are several ways to invoke the tool:
# To activate the constraint again, select it, and press {{Button|[[File:Sketcher_ToggleActiveConstraint.svg|16px]] [[Sketcher_ToggleActiveConstraint|ToggleActiveConstraint]]}} again.
#* Press the {{Button|[[Image:Sketcher_ToggleActiveConstraint.svg|16px]] [[Sketcher_ToggleActiveConstraint|Activate/deactivate constraint]]}} button.
#* Select the {{MenuCommand|Sketch → Sketcher constraints → [[Image:Sketcher_ToggleActiveConstraint.svg|16px]] Activate/deactivate constraint}} option from the menu.
#* {{Version|0.22}}: Right-click in the [[3D_view|3D view]] and select the {{MenuCommand|[[Image:Sketcher_ToggleActiveConstraint.svg|16px]] Activate/deactivate constraint}} option from the context menu.
#* In the '''Constraints''' section of the [[Sketcher_Dialog|Sketcher Dialog]] select the {{MenuCommand|Activate}} or {{MenuCommand|Deactivate}} option from the context menu. The offered option depends on the state of the constraint under the cursor.
#* Use the keyboard shortcut: {{KEY|K}} then {{KEY|Z}}.
# Active selected constraints are deactivated and turn grey (default [[Sketcher_Preferences#Appearance|color]]), while deactivated selected constraints are activated and return to red (default color).


== Examples ==
== Example == <!--T:8-->


</translate>
</translate>
[[File:Sketcher_ToggleActiveConstraint_example_active.png|x350px]]
[[File:Sketcher_ToggleActiveConstraint_example_active.png|400px]]
<translate>
<translate>
<!--T:9-->
{{Caption|Fully constrained sketch.}}
{{Caption|A fully constrained sketch.}}


</translate>
</translate>
[[File:Sketcher_ToggleActiveConstraint_example_disabled_1.png|x350px]] [[File:Sketcher_ToggleActiveConstraint_example_disabled_2.png|x350px]]
[[File:Sketcher_ToggleActiveConstraint_example_disabled_1.png|400px]]
<translate>
<translate>
<!--T:10-->
{{Caption|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.}}
{{Caption|One of the angular constraints has been deactivated, the sketch is no longer fully constrained.}}


</translate>
[[File:Sketcher_ToggleActiveConstraint_task_panel.png|x350px]]
[[File:Sketcher_ToggleActiveConstraint_example_disabled_2.png|400px]]
{{Caption|Task panel with the deactivated constraint.}}
<translate>
<!--T:18-->
{{Caption|The unconstrained geometry can be moved around. The deactivated constraint is still available, and can be re-activated to return to the fully constrained sketch.}}


== Scripting ==
== Scripting == <!--T:12-->


<!--T:13-->
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].


<!--T:14-->
The active status of a constraint can be controlled in [[macros|macros]] and from the [[Python_console|Python console]].
The active status of a constraint can be controlled in [[macros|macros]] and from the [[Python_console|Python console]].
</translate>
</translate>
{{Code|code=
{{Code|code=
SketchObject.toggleActive(number)
SketchObject.toggleActive(index)
}}
}}
<translate>
<translate>


<!--T:15-->
Use the {{incode|toggleActive}} method of an existing [[Sketcher_SketchObject|Sketcher SketchObject]], and the {{incode|number}} of the constraint to activate it or deactivate it.
Use the {{incode|toggleActive}} method of an existing [[Sketcher_SketchObject|Sketcher SketchObject]], and the {{incode|index}} of the constraint to activate it or deactivate it. The index starts from {{incode|0}} all the way to {{incode|N-1}}, where {{incode|N}} is the total number of constraints.


<!--T:16-->
Example:
Example:
</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD App
import FreeCAD as App


sketch = App.ActiveDocument.Sketch
sketch = App.ActiveDocument.Sketch
Line 69: Line 89:
<translate>
<translate>



<!--T:17-->
{{Docnav
{{Docnav
|[[Sketcher_ToggleDrivingConstraint|Toggle driving/reference constraint]]
|[[Sketcher_ConstrainInternalAlignment|Internal Alignment]]
|[[Sketcher_SelectElementsWithDoFs|Select solver DOFs]]
|[[Sketcher_SelectElementsWithDoFs|Select unconstrained DoF]]
|[[Sketcher_Workbench|Sketcher]]
|[[Sketcher_Workbench|Sketcher]]
|IconL=Sketcher_ToggleDrivingConstraint.svg
|IconL=Constraint_InternalAlignment.png
|IconR=Sketcher_SelectElementsWithDoFs.svg
|IconC=Workbench_Sketcher.svg
|IconC=Workbench_Sketcher.svg
|IconR=Sketcher SelectElementsWithDoFs.svg
}}
}}

</translate>
</translate>
{{Sketcher Tools navi{{#translation:}}}}
{{Sketcher_Tools_navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}

Revision as of 08:21, 19 April 2024

Sketcher ToggleActiveConstraint

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

Description

The Sketcher ToggleActiveConstraint tool activates or deactivates selected constraints. Deactivating constraints allows you to test other geometry arrangements without deleting constraints.

This is tool is similar to Sketcher ToggleDrivingConstraint, but contrary to that tool also works for geometric constraints, and values of deactivated dimensional constraints are preserved.

Usage

  1. Select one or more constraints.
  2. There are several ways to invoke the tool:
    • 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 Sketcher Dialog select the Activate or Deactivate option from the context menu. The offered option depends on the state of the constraint under the cursor.
    • Use the keyboard shortcut: K then Z.
  3. Active selected constraints are deactivated and turn grey (default color), while deactivated selected constraints are activated and return to red (default color).

Example

A fully constrained sketch.

One of the angular constraints has been deactivated, the sketch is no longer fully constrained.

The unconstrained geometry can be moved around. The deactivated constraint is still available, and can be re-activated to return to the fully constrained sketch.

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)