Draft AutoGroup: Difference between revisions

From FreeCAD Documentation
No edit summary
(Usage...)
Line 36: Line 36:
{{Caption|Draft Tray which sets the active auto-group by clicking on the folder icon and choosing a group}}
{{Caption|Draft Tray which sets the active auto-group by clicking on the folder icon and choosing a group}}


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


<!--T:3-->
<!--T:3-->
# To use this command at least one [[Draft_Layer|Draft Layer]] must exist.
# Select a {{Button|[[Image:Group.svg|16px]] [[Std_Group|Std Group]]}}, {{Button|[[Image:Group.svg|16px]] [[Draft_ToggleConstructionMode|Construction group]]}} in the tree view.
# Optionally select the layer you want make active in the [[Tree_view|Tree view]].
# Press the {{Button|[[Image:Draft AutoGroup_off.svg|16px]] None}} button, or go to the menu {{MenuCommand|Utilities → [[Image:Draft AutoGroup.svg|16px]] [[Draft AutoGroup|AutoGroup]]}}. If no group is selected, a drop-down menu will display eligible groups to use, or "None".
# There are several ways to invoke the command:
# The button will change with the name of the active auto-group, for example, {{Button|[[Image:Draft AutoGroup_on.svg|16px]] Group}}.
#* 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 its {{PropertyView|Line Color}}, its {{PropertyView|Shape Color}} and its name.
#* Select the {{MenuCommand|Utilities → [[Image:Draft_AutoGroup.svg|16px]] AutoGroup}} option from the menu.
# If you have not yet selected a layer: select a layer from the menu that opens.
# The button in the [[Draft_Tray|Draft Tray]] is updated.

==Notes==


<!--T:5-->
<!--T:5-->
* If [[Draft ToggleConstructionMode|Draft construction mode]] is on the active [[Draft_Layer|Draft Layer]] is ignored.
Notes:
* At least one of {{Button|[[Image:Group.svg|16px]] [[Std Group|Std Group]]}} or {{Button|[[Image:Group.svg|16px]] [[Draft_ToggleConstructionMode|Construction group]]}} must exist before using this tool.
* When auto-grouping is active, new [[Draft Workbench|Draft]] and [[Arch Workbench|Arch]] objects will be placed in that group except when {{Button|[[Image:Draft Construction.svg|16px]] [[Draft_ToggleConstructionMode|Construction mode]]}} is on, in which case the new geometry will be placed in the Construction group.


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

Revision as of 07:48, 28 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 AutoGroup tool sets a selected Std Group, or a related element like an Arch Site, an Arch Building or an Arch BuildingPart, as the active auto-group. When an auto-group is set, new objects will be automatically moved to the indicated group upon being created.

Auto-grouping works with elements created with the Draft and Arch Workbenches.

File:Draft AutoGroup example.png

Draft Tray which sets the active auto-group by clicking on the folder icon and choosing a group

Usage

  1. To use this command at least one Draft Layer must exist.
  2. Optionally select the layer you want 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 its ViewLine Color, its ViewShape Color and its name.
    • Select the Utilities → AutoGroup option from the menu.
  4. If you have not yet selected a layer: select a layer from the menu that opens.
  5. The button in the Draft Tray is updated.

Notes

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 auto-group, or is None if no auto-group is active. To change the active auto-group use the setAutoGroup method of the draftToolBar object. To put objects in the active auto-group 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()