Draft AutoGroup: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
(Use image for Tray button.)
 
(88 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<translate>

<!--T:14-->
{{Docnav
|[[Draft_ToggleConstructionMode|ToggleConstructionMode]]
|[[Draft_Snap_Lock|Snap Lock]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_ToggleConstructionMode.svg
|IconR=Draft_Snap_Lock.svg
|IconC=Workbench_Draft.svg
}}

<!--T:1-->
<!--T:1-->
{{GuiCommand
{{GuiCommand|Name=Draft AutoGroup|Workbenches=[[Draft Module|Draft]], [[Arch Module|Arch]]|MenuLocation=Draft → Utilities → AutoGroup|SeeAlso=}}
|Name=Draft AutoGroup
|Empty=1
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]]
|Version=0.17
|SeeAlso=[[Draft_Layer|Draft Layer]], [[Std_Group|Std Group]]
}}

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

<!--T:2-->
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-->
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.


</translate>
</translate>
[[Image:Draft_AutoGroup_example.jpg]]
[[Image:Draft_tray_menu.png]]
<translate>
<translate>
<!--T:9-->
{{Caption|The layer menu of the Draft Tray}}


== Description == <!--T:2-->
==Usage== <!--T:18-->
This tool allows to set a Group, or derivated like [[Draft VisGroup]], [[Arch Site]], [[Arch Building]] or [[Arch Floor]], as Active auto-group. When an auto-group is set, all new objects created in [[Draft Workbench]] or [[Arch Workbench]] will be placed into that group.


== How to use == <!--T:3-->
<!--T:3-->
# Optionally select the layer you want to make active in the [[Tree_view|Tree view]].
# Select menu Draft -> Utilities -> {{KEY|[[Image:Draft AutoGroup.png|16px]] [[Draft AutoGroup|AutoGroup]]}}, or click the autogroup button on the toolbar, or right-click a Group object in the tree view -> Utilities -> {{KEY|[[Image:Draft AutoGroup.png|16px]] [[Draft AutoGroup|AutoGroup]]}}
# Choose the desired group in the drop-down box
# There are several ways to invoke the command:
#* Press the [[Image:Draft_tray_button_layer.png]] 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.
#* 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:
#* Select {{MenuCommand|None}} to work without an active layer.
#* Select an existing layer to make active.
#* Select {{MenuCommand|Add new Layer}} to create a new layer. Selecting this option will not change the active layer.
# If the active layer was changed the button in the [[Draft_Tray|Draft Tray]] is updated.


== Options == <!--T:4-->
==Notes== <!--T:20-->


<!--T:5-->
<!--T:5-->
* 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.
* When AutoGroup is set, the button turns green, it means autogrouping is activated. You can click on it to change the group or unset.
* If [[Draft_ToggleConstructionMode|Draft construction mode]] is switched on the active [[Draft_Layer|layer]] is ignored.
* When autogrouping is active, any new Draft or Arch object created will be placed in that group (except when Draft construction mode is on, in which case it goes to the construction group).

* This only works when creating Draft or Arch objects from the GUI buttons. Not when using them from python. This is so it is still possible for python scripts to do the grouping they want, regardless of what autogrouping says.
==Preferences== <!--T:21-->

<!--T:22-->
See also: [[Preferences_Editor|Preferences Editor]] and [[Draft_Preferences|Draft Preferences]].

<!--T:23-->
* This command can optionally also handle groups: {{MenuCommand|Edit → Preferences... → Draft → General → Include groups in layer list}}.


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

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


<!--T:7-->
<!--T:7-->
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.
In python scripts, using Draft autogrouping is simply done with the command below:


</translate>
</translate>
{{Code|code=
{{Code|code=
# This code only works if the Draft Workbench is active!

import FreeCAD as App
import FreeCADGui as Gui
import Draft
import Draft

Draft.autogroup(object)
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()
}}
}}
<translate>



<languages/>
<!--T:13-->
{{Docnav
|[[Draft_ToggleConstructionMode|ToggleConstructionMode]]
|[[Draft_Snap_Lock|Snap Lock]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_ToggleConstructionMode.svg
|IconR=Draft_Snap_Lock.svg
|IconC=Workbench_Draft.svg
}}

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

Latest revision as of 17:37, 3 December 2023

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. Optionally select the layer you want to make active in the Tree view.
  2. There are several ways to invoke the command:
    • Press the 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.
  3. 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.
  4. 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 → Include groups in layer list.

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