Draft Layer: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(Scripting...)
Line 48: Line 48:


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


<!--T:14-->
<!--T:14-->
To add or remove objects from the layer, simply overwrite its {{incode|Group}} attribute.
To create a layer use the {{incode|make_layer}} method of the Draft module. Change a layer's {{incode|Group}} property to add or remove objects.


</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD as App
group = App.ActiveDocument.Layer.Group
import Draft
group.append(App.ActiveDocument.Wire)

App.ActiveDocument.Layer.Group = group
doc = App.newDocument()

layer = Draft.make_layer()
lay_vobj = layer.ViewObject
lay_vobj.LineColor = (1.0, 0.0, 0.0, 0.0) # red
lay_vobj.ShapeColor = (1.0, 1.0, 0.0, 0.0) # yellow

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

doc.recompute()
}}
}}
<translate>
<translate>

Revision as of 12:46, 4 August 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 Layer

Menu location
Utilities → Layer
Workbenches
Draft, Arch
Default shortcut
None
Introduced in version
0.19
See also
None

Description

The Draft Layer creates a special kind of group that controls the visual properties of objects placed inside of it. By changing the properties of the Layer, such as line width, line color, shape color and transparency, the changes are propagated to the objects that make use of the Layer property.

This tool replaces Draft VisGroup starting from FreeCAD 0.19.

Note: The BIM Workbench offers a complete layer manager tool, which will eventually be included in Draft.

Usage

  1. Go to the menu Draft → Utilities → Layer. This adds a new layer. If it is a the first layer, a Layers object will be created too, which contains all the layers.
  2. To add objects you can drag them into the layer. This will remove the objects from there original layer. If you want to have an object in several layers, e.g. to control the visibility of different sets of objects, you have to edit the Group property of the layer. Click the button occurring to the right and select/deselect the objects you want to have in or out of the layer.
  3. Change the desired view properties of the Layer.

Properties

  • DataGroup: specifies the elements that are part of the group.
  • Visual properties that can be changed that are propagated to the objects: ViewDrawing Style, ViewLine Color, ViewLine Width, ViewShape Color, ViewTransparency, and ViewVisibility.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To create a layer use the make_layer method of the Draft module. Change a layer's Group property to add or remove objects.

import FreeCAD as App
import Draft

doc = App.newDocument()

layer = Draft.make_layer()
lay_vobj = layer.ViewObject
lay_vobj.LineColor  = (1.0, 0.0, 0.0, 0.0) # red
lay_vobj.ShapeColor = (1.0, 1.0, 0.0, 0.0) # yellow

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

doc.recompute()