Draft AutoGroup: Difference between revisions

From FreeCAD Documentation
No edit summary
(The command was removed from the Utilities menu in V0.20. See https://github.com/FreeCAD/FreeCAD/pull/4882. The command icon is no longer used in the GUI.)
(7 intermediate revisions by 2 users not shown)
Line 6: Line 6:
|[[Draft_ToggleConstructionMode|ToggleConstructionMode]]
|[[Draft_ToggleConstructionMode|ToggleConstructionMode]]
|[[Draft_Snap_Lock|Snap Lock]]
|[[Draft_Snap_Lock|Snap Lock]]
|[[Draft_Module|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_ToggleConstructionMode.svg
|IconL=Draft_ToggleConstructionMode.svg
|IconR=Draft_Snap_Lock.svg
|IconR=Draft_Snap_Lock.svg
Line 15: Line 15:
{{GuiCommand
{{GuiCommand
|Name=Draft AutoGroup
|Name=Draft AutoGroup
|Empty=1
|MenuLocation=Utilities → AutoGroup
|Workbenches=[[Draft_Module|Draft]], [[Arch_Module|Arch]]
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]]
|Version=0.17
|Version=0.17
|SeeAlso=[[Draft_Layer|Draft Layer]], [[Std_Group|Std Group]]
|SeeAlso=[[Draft_Layer|Draft Layer]], [[Std_Group|Std Group]]
Line 24: Line 24:


<!--T:2-->
<!--T:2-->
The [[Image:Draft_AutoGroup.svg|24px]] '''Draft AutoGroup''' command changes the active [[Draft_Layer|Draft Layer]] or, [[#Preferences|optionally]], the active [[Std_Group|Std Group]] or group-like [[Arch_Module|Arch]] object. New [[Draft_Module|Draft]] and [[Arch_Module|Arch]] objects are automatically placed in this active layer or group.
The '''Draft AutoGroup''' command changes the active [[Draft_Layer|Draft Layer]] or, [[#Preferences|optionally]], the active [[Std_Group|Std Group]] or group-like [[Arch_Workbench|Arch]] object. New [[Draft_Workbench|Draft]] and [[Arch_Workbench|Arch]] objects are automatically placed in this active layer or group.


<!--T:19-->
<!--T:19-->
Line 38: Line 38:


<!--T:3-->
<!--T:3-->
# To use this command in FreeCAD version 0.19 at least one [[Draft_Layer|Draft Layer]] must exist.
# To use this command in FreeCAD version 0.19 at least one [[Draft_Layer|layer]] must exist.
# Optionally select the layer you want to make active in the [[Tree_view|Tree view]].
# Optionally select the layer you want to make active in the [[Tree_view|Tree view]].
# There are several ways to invoke the command:
# There are several ways to invoke the command:
#* Press the {{Button|[[Image:button_invalid.svg|16px]] [[Draft_AutoGroup|None]]}} button in the [[Draft_Tray|Draft Tray]]. This button can look different. If there is an active layer it will show the name of the layer and a layer icon with the {{PropertyView|Line Color}} and {{PropertyView|Shape Color}} of the layer.
#* Press the {{Button|[[Image:button_invalid.svg|16px]] [[Draft_AutoGroup|None]]}} button in the [[Draft_Tray|Draft Tray]]. This button can look different. If there is an active layer it will show the name of the layer and a layer icon with the {{PropertyView|Line Color}} and {{PropertyView|Shape Color}} of the layer.
#* Select the {{MenuCommand|Utilities → [[Image:Draft_AutoGroup.svg|16px]] AutoGroup}} option from the menu.
#* If you have selected a layer: select the {{MenuCommand|[[Image:button_right.svg|16px]] Activate this layer}} option from the [[Tree_view|Tree view]] context menu.
# If you have not yet selected a layer the layer menu opens. Do one of the following:
# If you have not yet selected a layer the layer menu opens. Do one of the following:
#* Select {{MenuCommand|None}} to work without an active layer.
#* Select {{MenuCommand|None}} to work without an active layer.
Line 52: Line 52:


<!--T:5-->
<!--T:5-->
* A layer can also be activated by right-clicking it in the [[Tree_view|Tree view]] and selecting the {{MenuCommand| [[Image:button_right.svg|16px]] Activate this layer}} option from the context menu.
* A new [[Draft_Layer|layer]] can also be created by right-clicking the layer container in the [[Tree_view|Tree view]] and selecting the {{MenuCommand|[[Image:Draft_NewLayer.svg|16px]] Add new layer}} option from the context menu.
* If [[Draft_ToggleConstructionMode|Draft construction mode]] is switched on the active [[Draft_Layer|layer]] is ignored.
* A new layer can also be created by right-clicking the layer container in the [[Tree_view|Tree view]] and selecting the {{MenuCommand| [[Image:Draft_NewLayer.svg|16px]] Add new layer}} option from the context menu.
* If [[Draft ToggleConstructionMode|Draft construction mode]] is switched on the active [[Draft_Layer|Draft Layer]] is ignored.


==Preferences== <!--T:21-->
==Preferences== <!--T:21-->
Line 67: Line 66:


<!--T:10-->
<!--T:10-->
See also: [https://freecad.github.io/SourceDoc/ Autogenerated API documentation] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].
See also: [https://freecad.github.io/SourceDoc/ Autogenerated API documentation] and [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]].


<!--T:7-->
<!--T:7-->
If the [[Draft_Module|Draft Workbench]] is active the FreeCADGui application object has a {{incode|draftToolBar}} property. This {{incode|draftToolBar}} object has an {{incode|autogroup}} property, which contains the name of the active autogroup, or is {{incode|None}} if no autogroup is active. To change the active autogroup use the {{incode|setAutoGroup}} method of the {{incode|draftToolBar}} object. To put objects in the active autogroup use the {{incode|autogroup}} method of the Draft module.
If the [[Draft_Workbench|Draft Workbench]] is active the FreeCADGui application object has a {{incode|draftToolBar}} property. This {{incode|draftToolBar}} object has an {{incode|autogroup}} property, which contains the name of the active autogroup, or is {{incode|None}} if no autogroup is active. To change the active autogroup use the {{incode|setAutoGroup}} method of the {{incode|draftToolBar}} object. To put objects in the active autogroup use the {{incode|autogroup}} method of the Draft module.


</translate>
</translate>
Line 102: Line 101:
|[[Draft_ToggleConstructionMode|ToggleConstructionMode]]
|[[Draft_ToggleConstructionMode|ToggleConstructionMode]]
|[[Draft_Snap_Lock|Snap Lock]]
|[[Draft_Snap_Lock|Snap Lock]]
|[[Draft_Module|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_ToggleConstructionMode.svg
|IconL=Draft_ToggleConstructionMode.svg
|IconR=Draft_Snap_Lock.svg
|IconR=Draft_Snap_Lock.svg

Revision as of 13:07, 2 September 2021

Draft AutoGroup

Menu location
None
Workbenches
Draft, Arch
Default shortcut
None
Introduced in version
0.17
See also
Draft Layer, Std Group

Description

The Draft AutoGroup command changes the active Draft Layer or, optionally, the active Std Group or group-like Arch object. New Draft and Arch objects are automatically placed in this active layer or group.

This command was originally intended for groups, hence its name, but was redesigned in FreeCAD version 0.19 when a layer system was introduced. Because handling layers is now the default for the command the rest of this page will primarily focus on layers.

The layer menu of the Draft Tray

Usage

  1. To use this command in FreeCAD version 0.19 at least one layer must exist.
  2. Optionally select the layer you want to make active in the Tree view.
  3. There are several ways to invoke the command:
    • Press the None button in the Draft Tray. This button can look different. If there is an active layer it will show the name of the layer and a layer icon with the ViewLine Color and ViewShape Color of the layer.
    • If you have selected a layer: select the Activate this layer option from the Tree view context menu.
  4. If you have not yet selected a layer the layer menu opens. Do one of the following:
    • Select None to work without an active layer.
    • Select an existing layer to make active.
    • Select Add new Layer to create a new layer. Selecting this option will not change the active layer.
  5. If the active layer was changed the button in the Draft Tray is updated.

Notes

  • A new layer can also be created by right-clicking the layer container in the Tree view and selecting the Add new layer option from the context menu.
  • If Draft construction mode is switched on the active layer is ignored.

Preferences

See also: Preferences Editor and Draft Preferences.

  • This command can optionally also handle groups: Edit → Preferences... → Draft → General settings → General Draft Settings → Show groups in layers list drop-down button.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

If the Draft Workbench is active the FreeCADGui application object has a draftToolBar property. This draftToolBar object has an autogroup property, which contains the name of the active autogroup, or is None if no autogroup is active. To change the active autogroup use the setAutoGroup method of the draftToolBar object. To put objects in the active autogroup use the autogroup method of the Draft module.

# This code only works if the Draft Workbench is active!

import FreeCAD as App
import FreeCADGui as Gui
import Draft

doc = App.newDocument()

polygon1 = Draft.make_polygon(5, radius=1000)
polygon2 = Draft.make_polygon(3, radius=500)
polygon3 = Draft.make_polygon(6, radius=220)

layer = Draft.make_layer()
Gui.draftToolBar.setAutoGroup(layer.Name)

Draft.autogroup(polygon1)
Draft.autogroup(polygon2)
Draft.autogroup(polygon3)

doc.recompute()