Draft Downgrade: Difference between revisions

From FreeCAD Documentation
m (Added templates)
(Button text.)
 
(26 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:19-->
<!--T:19-->
{{Docnav
{{Docnav
|[[Draft_Upgrade|Upgrade]]
|[[Draft_Upgrade|Upgrade]]
|[[Draft_WireToBSpline|WireToBSpline]]
|[[Draft_Scale|Scale]]
|[[Draft_Module|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_Upgrade.svg
|IconL=Draft_Upgrade.svg
|IconR=Draft_WireToBSpline.svg
|IconC=Workbench_Draft.svg
|IconC=Workbench_Draft.svg
|IconR=Draft_Scale.svg
}}
}}


Line 14: Line 15:
{{GuiCommand
{{GuiCommand
|Name=Draft Downgrade
|Name=Draft Downgrade
|MenuLocation=Draft → Downgrade
|MenuLocation=Modification → Downgrade
|Workbenches=[[Draft Module|Draft]], [[Arch Module|Arch]]
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]]
|Shortcut={{KEY|D}} {{KEY|N}}
|Shortcut={{KEY|D}} {{KEY|N}}
|SeeAlso=[[Draft Upgrade|Draft Upgrade]], [[Part Cut|Part Cut]]
|SeeAlso=[[Draft_Upgrade|Draft Upgrade]], [[Part_Cut|Part Cut]]
}}
}}


Line 23: Line 24:


<!--T:3-->
<!--T:3-->
The [[Image:Draft_Downgrade.svg|24px]] '''Draft Downgrade''' command downgrades selected objects. The result depends on the number of selected objects and their type. The command can for example deconstruct a 3D solid into separate faces and a wire into separate edges. If two face are selected a [[Part_Cut|Part Cut]] object is created from them. Note that not all objects can be downgraded. This command is the counterpart of the [[Draft_Upgrade|Draft Upgrade]] command.
The {{Button|[[Image:Draft Downgrade.png|16px]] [[Draft Downgrade|Draft Downgrade]]}} tool downgrades the selected objects in different ways.

<!--T:14-->
The Downgrade tool performs things such as breaking faces, and deconstructing wires into their individual edges. It can cut a shape with another shape in similar way to {{Button|[[Image:Part_Cut.svg|16px]] [[Part Cut|Part Cut]]}}.

<!--T:15-->
The counterpart to this tool is the {{Button|[[Image:Draft Upgrade.png|16px]] [[Draft Upgrade|Draft Upgrade]]}} operation.


</translate>
</translate>
Line 35: Line 30:
<translate>
<translate>
<!--T:16-->
<!--T:16-->
{{Caption|Face cut from another face; then face downgraded into a closed wire; then downgraded into individual lines}}
{{Caption|Two overlapping faces are downgraded to a Part Cut object, which is downgraded to a face. That face is then downgraded to a closed wire, which is finally downgraded to separate edges.}}


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


<!--T:5-->
<!--T:5-->
# Select one or more objects that you want to downgrade.
# Optionally select one or more objects.
# There are several ways to invoke the command:
# Press the {{Button|[[Image:Draft Downgrade.png|16px]] [[Draft Downgrade|Draft Downgrade]]}} button or press {{KEY|D}} then {{KEY|N}} keys. If no object is selected, you will be invited to select one.
#* Press the {{Button|[[Image:Draft_Downgrade.svg|16px]] [[Draft_Downgrade|Downgrade]]}} button.
#* Select the {{MenuCommand|Modification → [[Image:Draft_Downgrade.svg|16px]] Downgrade}} option from the menu.
#* Use the keyboard shortcut: {{KEY|D}} then {{KEY|N}}.
# If you have not yet selected an object: select an object in the [[3D_view|3D view]].


<!--T:17-->
==Scripting== <!--T:22-->
The selected objects are modified or downgraded, according to the following conditions, in order:
# If only one object is selected and it contains more than one face, each face becomes a separate object.
# If there are more than one face in the selection, the subsequent objects are subtracted from the first one.
# If there is only one face in the selection, it gets converted into a wire.
# Otherwise all wires found in the selection are exploded into single edges.


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

<!--T:7-->
There are no options for this tool. Either it works with the selected objects or not.

==Example== <!--T:8-->

<!--T:9-->
<gallery widths="300" heights="200">
File:Draft Downgrade 01.png|Complete shape
File:Draft Downgrade 02.png|Downgraded shape, with disconnected and split faces
</gallery>

==Scripting== <!--T:10-->
{{Emphasis|See also:}} [[Draft API|Draft API]] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].


<!--T:11-->
<!--T:11-->
To downgrade objects use the {{incode|downgrade}} method of the Draft module.
The Downgrade tool can be used in [[macros|macros]] and from the [[Python|Python]] console by using the following function:


</translate>
</translate>
{{Code|code=
{{Code|code=
downgrade_list = downgrade(objects, delete=False, force=None)
downgrade_list = downgrade(objects, delete=False, force=None)
addList, deleteList = downgrade(objects, delete=False, force=None)
}}
}}
<translate>
<translate>


<!--T:12-->
<!--T:12-->
* Downgrades the given {{incode|objects}}, which can be a single object or a list of objects.
* {{incode|objects}} contains the objects to be downgraded. It is either a single object or a list of objects.
* If {{incode|delete}} is {{incode|True}}, old objects are deleted.
* If {{incode|delete}} is {{incode|True}} the source objects are deleted.
* If {{incode|force}} is given, it is the internal function to call to force a certain way of downgrading. It can be: {{incode|"explode"}}, {{incode|"shapify"}}, {{incode|"subtr"}}, {{incode|"splitFaces"}}, {{incode|"cut2"}}, {{incode|"getWire"}}, or {{incode|"splitWires"}}.
* {{incode|force}} forces a certain way of downgrading by calling a specific internal function. It can be: {{incode|"explode"}}, {{incode|"shapify"}}, {{incode|"subtr"}}, {{incode|"splitFaces"}}, {{incode|"cut2"}}, {{incode|"getWire"}}, {{incode|"splitWires"}} or {{incode|"splitCompounds"}}.
* {{incode|upgrade_list}} is returned, which is a list containing two lists: a list of new objects ({{incode|addList}}) and a list of objects to be deleted ({{incode|deleteList}}).
* {{incode|downgrade_list}} is returned. It is a list containing two lists: a list of new objects and a list of objects to be deleted. If {{incode|delete}} is {{incode|True}} the second list is empty.


<!--T:13-->
<!--T:13-->
Line 87: Line 67:
</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD, Draft
import FreeCAD as App
import Draft


doc = App.newDocument()
# Create an union
Circle = Draft.makeCircle(1000)
Rectangle = Draft.makeRectangle(2000, 800)


circle = Draft.make_circle(1000)
addList1, deleteList1 = Draft.upgrade([Circle, Rectangle], delete=True)
rectangle = Draft.make_rectangle(2000, 800)
union = addList1[0]
doc.recompute()


add_list1, delete_list1 = Draft.upgrade([circle, rectangle], delete=True)
# Downgrade the union twice
addList2, deleteList2 = Draft.downgrade(union, delete=False)
wire = addList2[0]


compound = add_list1[0]
list_edges, deleteList3 = Draft.downgrade(wire, delete=False)
add_list2, delete_list2 = Draft.downgrade(compound, delete=False)
face = add_list2[0]
add_list3, delete_list3 = Draft.downgrade(face, delete=False)


box = doc.addObject("Part::Box", "Box")
# Insert a solid box
box.Length = 2300
Box = FreeCAD.ActiveDocument.addObject("Part::Box", "Box")
Box.Length = 2300
box.Width = 800
Box.Width = 800
box.Height = 1000
Box.Height = 1000


list_faces, deleteList4 = Draft.downgrade(Box, delete=True)
add_list4, delete_list4 = Draft.downgrade(box, delete=True)

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



<!--T:18-->
<!--T:18-->
{{Docnav
{{Docnav
|[[Draft_Upgrade|Upgrade]]
|[[Draft_Upgrade|Upgrade]]
|[[Draft_WireToBSpline|WireToBSpline]]
|[[Draft_Scale|Scale]]
|[[Draft_Module|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_Upgrade.svg
|IconL=Draft_Upgrade.svg
|IconR=Draft_WireToBSpline.svg
|IconC=Workbench_Draft.svg
|IconC=Workbench_Draft.svg
|IconR=Draft_Scale.svg
}}
}}


<!--T:20-->
{{Draft Tools navi}}

<!--T:21-->
{{Userdocnavi}}
</translate>
</translate>
{{Draft Tools navi{{#translation:}}}}
{{clear}}
{{Userdocnavi{{#translation:}}}}

Latest revision as of 17:11, 3 December 2023

Draft Downgrade

Menu location
Modification → Downgrade
Workbenches
Draft, Arch
Default shortcut
D N
Introduced in version
-
See also
Draft Upgrade, Part Cut

Description

The Draft Downgrade command downgrades selected objects. The result depends on the number of selected objects and their type. The command can for example deconstruct a 3D solid into separate faces and a wire into separate edges. If two face are selected a Part Cut object is created from them. Note that not all objects can be downgraded. This command is the counterpart of the Draft Upgrade command.

Two overlapping faces are downgraded to a Part Cut object, which is downgraded to a face. That face is then downgraded to a closed wire, which is finally downgraded to separate edges.

Usage

  1. Optionally select one or more objects.
  2. There are several ways to invoke the command:
    • Press the Downgrade button.
    • Select the Modification → Downgrade option from the menu.
    • Use the keyboard shortcut: D then N.
  3. If you have not yet selected an object: select an object in the 3D view.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To downgrade objects use the downgrade method of the Draft module.

downgrade_list = downgrade(objects, delete=False, force=None)
  • objects contains the objects to be downgraded. It is either a single object or a list of objects.
  • If delete is True the source objects are deleted.
  • force forces a certain way of downgrading by calling a specific internal function. It can be: "explode", "shapify", "subtr", "splitFaces", "cut2", "getWire", "splitWires" or "splitCompounds".
  • downgrade_list is returned. It is a list containing two lists: a list of new objects and a list of objects to be deleted. If delete is True the second list is empty.

Example:

import FreeCAD as App
import Draft

doc = App.newDocument()

circle = Draft.make_circle(1000)
rectangle = Draft.make_rectangle(2000, 800)
doc.recompute()

add_list1, delete_list1 = Draft.upgrade([circle, rectangle], delete=True)

compound = add_list1[0]
add_list2, delete_list2 = Draft.downgrade(compound, delete=False)
face = add_list2[0]
add_list3, delete_list3 = Draft.downgrade(face, delete=False)

box = doc.addObject("Part::Box", "Box")
box.Length = 2300
box.Width = 800
box.Height = 1000

add_list4, delete_list4 = Draft.downgrade(box, delete=True)

doc.recompute()