Draft AutoGroup: Difference between revisions

From FreeCAD Documentation
No edit summary
No edit summary
Line 39: Line 39:
<!--T:3-->
<!--T:3-->
# To use this command at least one [[Draft_Layer|Draft Layer]] must exist.
# To use this command at least one [[Draft_Layer|Draft Layer]] must exist.
# Optionally select the layer you want 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.
Line 45: Line 45:
# 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.
#* Select an existing layer to make active.
#* Select the existing layer you want to make active.
#* Select {{MenuCommand|Add new Layer}} to create a new layer. Selecting this option will not change the active layer.
#* Select {{MenuCommand|Add new Layer}} to create a new layer. Selecting this option will not change the active layer.
# The button in the [[Draft_Tray|Draft tray]] is updated if the active layer has changed.
# The button in the [[Draft_Tray|Draft tray]] is updated if the active layer has changed.

Revision as of 11:04, 29 July 2021

This documentation is a work in progress. Please don't mark it as translatable since it will change in the next hours and days.

Draft AutoGroup

Menu location
Utilities → AutoGroup
Workbenches
Draft, Arch
Default shortcut
None
Introduced in version
0.17
See also
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 text will primarily focus on layers.

The layer menu of the Draft tray

Usage

  1. To use this command at least one Draft 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.
    • Select the Utilities → AutoGroup option from the 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 the existing layer you want to make active.
    • Select Add new Layer to create a new layer. Selecting this option will not change the active layer.
  5. The button in the Draft tray is updated if the active layer has changed.

Notes

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()