Draft Upgrade: Difference between revisions

From FreeCAD Documentation
m ({{Code|code=)
(Button text.)
 
(70 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<translate>

<!--T:20-->
{{Docnav
|[[Draft_Split|Split]]
|[[Draft_Downgrade|Downgrade]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_Split.svg
|IconR=Draft_Downgrade.svg
|IconC=Workbench_Draft.svg
}}

<!--T:1-->
<!--T:1-->
{{GuiCommand
{{GuiCommand|Name=Draft Upgrade|Workbenches=[[Draft Module|Draft]], [[Arch Module|Arch]]|MenuLocation=Draft -> Upgrade|Shortcut=U P|SeeAlso=[[Draft Downgrade|Draft Downgrade]]}}
|Name=Draft Upgrade
|MenuLocation=Modification → Upgrade
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]]
|Shortcut={{KEY|U}} {{KEY|P}}
|SeeAlso=[[Draft_Downgrade|Draft Downgrade]]
}}


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


<!--T:3-->
<!--T:3-->
The [[Image:Draft_Upgrade.svg|24px]] '''Draft Upgrade''' command upgrades selected objects. The result depends on the number of selected objects and their type. The command can for example fuse elements and create faces. It is worth trying to upgrade a selection several times to see if a better result can be obtained. See the example in the image. Note that not all objects can be upgraded. This command is the counterpart of the [[Draft_Downgrade|Draft Downgrade]] command.
This tool upgrades selected objects in different ways. If no object is selected, you will be invited to select one.


</translate>
</translate>
[[Image:Draft_Upgrade_example.jpg|400px]]
[[Image:Draft_Upgrade_example.jpg|400px]]
<translate>
<translate>
<!--T:15-->
{{Caption|An open non-editable wire is upgraded to a closed wire, and then to a face. A closed non-editable square wire is also upgraded to a face. The two faces are then upgraded to create a compound, which is finally upgraded to a single editable Draft Wire.}}


==How to use== <!--T:4-->
==Usage== <!--T:4-->


<!--T:5-->
<!--T:5-->
# Select one or more objects you wish to upgrade
# Optionally select one or more objects.
# There are several ways to invoke the command:
# Press the {{KEY|[[Image:Draft Upgrade.png|16px]] [[Draft Upgrade]]}} button or press {{KEY|U}} then {{KEY|P}} keys
#* Press the {{Button|[[Image:Draft_Upgrade.svg|16px]] [[Draft_Upgrade|Upgrade]]}} button.
#* Select the {{MenuCommand|Modification → [[Image:Draft_Upgrade.svg|16px]] Upgrade}} option from the menu.
#* Use the keyboard shortcut: {{KEY|U}} then {{KEY|P}}.
# If you have not yet selected an object: select an object in the [[3D_view|3D view]].


==Options== <!--T:6-->
==Notes== <!--T:24-->


<!--T:7-->
<!--T:25-->
* [[Draft_Line|Draft Lines]] and [[Draft_Wire|Draft Wires]] can be joined with this command, but also with the [[Draft_Join|Draft Join]] command or the [[Draft_Wire|Draft Wire]] command.
The selected objects are modified/upgraded according to the following conditions (in order):
* if there are more than one face in the selection, the faces are merged (union)
* if there is only one face in the selection, nothing is done
* if there is only one open wire in the selection, it gets closed
* if there are only edges in the selection, all edges are joined into a wire (closed if possible)
* if none of the above is possible, a compound object is created


==Scripting== <!--T:8-->
==Scripting== <!--T:23-->

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


<!--T:9-->
<!--T:9-->
The upgrade tool can be used from python scripts and [[macros]] like this:
To upgrade objects use the {{incode|upgrade}} method of the Draft module.


</translate>
</translate>
{{Code|code=
{{Code|code=
Draft.upgrade(objects, delete=False, force=None)
upgrade_list = upgrade(objects, delete=False, force=None)
}}
}}
<translate>
<translate>


<!--T:10-->
<!--T:10-->
* Upgrades the given object(s) (can be an object or a list of objects).
* {{incode|objects}} contains the objects to be upgraded. It is either a single object or a list of objects.
* If delete is True, old objects are deleted.
* If {{incode|delete}} is {{incode|True}} the source objects are deleted.
* The force attribute can be used to force a certain way of upgrading. It can be: makeCompound, closeGroupWires, makeSolid, closeWire, turnToParts, makeFusion, makeShell, makeFaces, draftify, joinFaces, makeSketchFace, makeWires
* {{incode|force}} forces a certain way of upgrading by calling a specific internal function. It can be: {{incode|"makeCompound"}}, {{incode|"closeGroupWires"}}, {{incode|"makeSolid"}}, {{incode|"closeWire"}}, {{incode|"turnToParts"}}, {{incode|"makeFusion"}}, {{incode|"makeShell"}}, {{incode|"makeFaces"}}, {{incode|"draftify"}}, {{incode|"joinFaces"}}, {{incode|"makeSketchFace"}}, {{incode|"makeWires"}} or {{incode|"turnToLine"}}.
* Returns a dictionnary containing two lists, a list of new objects and a list of objects to be deleted
* {{incode|upgrade_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:11-->
Some of the operations of the Upgrade tool can also be made with the [[Part Fuse]] or [[Draft Wire]] tools.


<!--T:12-->
<!--T:12-->
Line 53: Line 72:
</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD as App
import Draft
import Draft

mycircle = Draft.makeCircle(2)
doc = App.newDocument()
face1 = Draft.upgrade([mycircle],True)

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

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

line1 = Draft.make_line(App.Vector(2000, 0, 0), App.Vector(2500, 1500, 0))
line2 = Draft.make_line(App.Vector(2500, 1500, 0), App.Vector(3000, -1000, 0))
doc.recompute()

add_list2, delete_list2 = Draft.upgrade([line1, line2], delete=False)

simple_wire = add_list2[0]
add_list3, delete_list3 = Draft.upgrade(simple_wire, delete=False)

closed_wire = add_list3[0]
add_list4, delete_list4 = Draft.upgrade(closed_wire, delete=False)

face = add_list4[0]
add_list5, delete_list5 = Draft.upgrade(face, delete=False)

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



<languages/>
<!--T:19-->
{{Docnav
|[[Draft_Split|Split]]
|[[Draft_Downgrade|Downgrade]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_Split.svg
|IconR=Draft_Downgrade.svg
|IconC=Workbench_Draft.svg
}}

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

Latest revision as of 17:11, 3 December 2023

Draft Upgrade

Menu location
Modification → Upgrade
Workbenches
Draft, Arch
Default shortcut
U P
Introduced in version
-
See also
Draft Downgrade

Description

The Draft Upgrade command upgrades selected objects. The result depends on the number of selected objects and their type. The command can for example fuse elements and create faces. It is worth trying to upgrade a selection several times to see if a better result can be obtained. See the example in the image. Note that not all objects can be upgraded. This command is the counterpart of the Draft Downgrade command.

An open non-editable wire is upgraded to a closed wire, and then to a face. A closed non-editable square wire is also upgraded to a face. The two faces are then upgraded to create a compound, which is finally upgraded to a single editable Draft Wire.

Usage

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

Notes

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

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

upgrade_list = upgrade(objects, delete=False, force=None)
  • objects contains the objects to be upgraded. 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 upgrading by calling a specific internal function. It can be: "makeCompound", "closeGroupWires", "makeSolid", "closeWire", "turnToParts", "makeFusion", "makeShell", "makeFaces", "draftify", "joinFaces", "makeSketchFace", "makeWires" or "turnToLine".
  • upgrade_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=False)

line1 = Draft.make_line(App.Vector(2000, 0, 0), App.Vector(2500, 1500, 0))
line2 = Draft.make_line(App.Vector(2500, 1500, 0), App.Vector(3000, -1000, 0))
doc.recompute()

add_list2, delete_list2 = Draft.upgrade([line1, line2], delete=False)

simple_wire = add_list2[0]
add_list3, delete_list3 = Draft.upgrade(simple_wire, delete=False)

closed_wire = add_list3[0]
add_list4, delete_list4 = Draft.upgrade(closed_wire, delete=False)

face = add_list4[0]
add_list5, delete_list5 = Draft.upgrade(face, delete=False)

doc.recompute()