Draft WireToBSpline: Difference between revisions

From FreeCAD Documentation
m (Changed section to 'Usage')
(In the context of scripting "module" is correct.)
 
(33 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:17-->
<!--T:17-->
{{Docnav
{{Docnav
|[[Draft_Downgrade|Downgrade]]
|[[Draft_SubelementHighlight|Subelement highlight]]
|[[Draft_Draft2Sketch|Draft2Sketch]]
|[[Draft_AddPoint|Add point]]|[[Draft_Module|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_SubelementHighlight.svg
|IconL=Draft_Downgrade.svg
|IconR=Draft_Draft2Sketch.svg
|IconC=Workbench_Draft.svg
|IconC=Workbench_Draft.svg
|IconR=Draft_AddPoint.svg
}}
}}


Line 13: Line 15:
{{GuiCommand
{{GuiCommand
|Name=Draft WireToBSpline
|Name=Draft WireToBSpline
|MenuLocation=Drafting → Wire to BSpline
|MenuLocation=Modification → Wire to B-spline
|Workbenches=[[Draft Module|Draft]], [[Arch Module|Arch]]
|Workbenches=[[Draft_Workbench|Draft]], [[Arch_Workbench|Arch]]
|SeeAlso=[[Draft Wire|Draft Wire]], [[Draft BSpline|Draft BSpline]]
|SeeAlso=[[Draft_Wire|Draft Wire]], [[Draft_BSpline|Draft BSpline]]
}}
}}


Line 21: Line 23:


<!--T:3-->
<!--T:3-->
This tool converts [[Draft Wire|Draft Wires]] to [[Draft BSpline|Draft BSplines]], and vice-versa.
The [[Image:Draft_WireToBSpline.svg|24px]] '''Draft WireToBSpline''' command converts [[Draft_Wire|Draft Wires]] to [[Draft_BSpline|Draft BSplines]] and vice versa.


</translate>
</translate>
[[Image:Draft Wire2BSpline example.jpg|400px]]
[[Image:Draft_Wire2BSpline_example.jpg|400px]]
<translate>
<translate>
<!--T:12-->
<!--T:12-->
{{Caption|Convertir a wire to a B-Spline, and a closed B-Spline to a closed wire}}
{{Caption|Converting a wire to a B-spline, and a closed B-spline to a closed wire}}


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


<!--T:5-->
<!--T:5-->
# Select a [[Draft Wire|Draft Wire]] or a [[Draft BSpline|Draft BSpline]]. The tool is disabled if no object is selected.
# Select a [[Draft_Wire|Draft Wire]] or a [[Draft_BSpline|Draft BSpline]].
# There are several ways to invoke the command:
# Press the {{Button|[[Image:Draft WireToBSpline.svg|16px]] [[Draft WireToBSpline|Draft WireToBSpline]]}} button.
#* Press the {{Button|[[Image:Draft_WireToBSpline.svg|16px]] [[Draft_WireToBSpline|Wire to B-spline]]}} button.
#* Select the {{MenuCommand|Modification → [[Image:Draft_WireToBSpline.svg|16px]] Wire to B-spline}} option from the menu.
# A new object is created.


<!--T:13-->
==Notes== <!--T:21-->
A new object will be created; the original object will not be modified.


<!--T:14-->
<!--T:22-->
{{Emphasis|Note:}} if a closed wire with sharp edges is used to create a spline, the new object may have self intersecting curve segments, and may not be visible in the 3D view. If this is the case, manually set {{PropertyData|Make Face}} to {{FALSE}} to see the new shape, or set {{PropertyData|Closed}} to {{FALSE}} to create an open shape.
* The command may result in a closed, self-intersecting [[Draft_Wire|Draft Wire]] or [[Draft_BSpline|Draft BSpline]] with a face. Such an object will not display properly in the [[3D_view|3D view]]. Its {{PropertyData|Make Face}} property, or its {{PropertyData|Closed}} property, must be set to {{FALSE}}.


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


<!--T:7-->
<!--T:8-->
See also: [https://freecad.github.io/SourceDoc/ Autogenerated API documentation] and [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]].
There are no options for this tool. Either it works with the selected object or not.

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


<!--T:9-->
<!--T:9-->
To convert a wire to a B-spline, or vice versa, pass the {{incode|Points}} property of the source object to the {{incode|[[Draft_BSpline#Scripting|make_bspline]]}} method, or respectively the {{incode|[[Draft_Wire#Scripting|make_wire]]}} method, of the Draft module.
There is no programming interface available for the WireToBSpline tool; however, creating a new object from the points of another is simple.

<!--T:15-->
The {{incode|Points}} attribute of an object is a list with the points that comprise that object; this list can be passed to functions that build geometry. Each point is defined by its {{incode|FreeCAD.Vector}}, with units in millimeters.


<!--T:10-->
<!--T:10-->
Example:
Example:

</translate>
</translate>
{{Code|code=
{{Code|code=
import FreeCAD, Draft
import FreeCAD as App
import Draft


doc = App.newDocument()
# Make a spline from the points of a wire
p1 = FreeCAD.Vector(1000, 1000, 0)
p2 = FreeCAD.Vector(2000, 1000, 0)
p3 = FreeCAD.Vector(2500, -1000, 0)
p4 = FreeCAD.Vector(3500, -500, 0)


base_wire = Draft.makeWire([p1, p2, p3, p4])
p1 = App.Vector(1000, 1000, 0)
p2 = App.Vector(2000, 1000, 0)
p3 = App.Vector(2500, -1000, 0)
p4 = App.Vector(3500, -500, 0)

base_wire = Draft.make_wire([p1, p2, p3, p4])
base_spline = Draft.make_bspline([-p1, -1.3*p2, -1.2*p3, -2.1*p4])


points1 = base_wire.Points
points1 = base_wire.Points
spline = Draft.makeBSpline(points1)
spline_from_wire = Draft.make_bspline(points1)

# Make a wire from the points of a spline
base_spline = Draft.makeBSpline([-p1, -1.3*p2, -1.2*p3, -2.1*p4])


points2 = base_spline.Points
points2 = base_spline.Points
Wire = Draft.makeWire(points2)
wire_from_spline = Draft.make_wire(points2)

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



<!--T:16-->
<!--T:16-->
{{Docnav
{{Docnav
|[[Draft_Downgrade|Downgrade]]
|[[Draft_SubelementHighlight|Subelement highlight]]
|[[Draft_Draft2Sketch|Draft2Sketch]]
|[[Draft_AddPoint|Add point]]
|[[Draft_Module|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=Draft_SubelementHighlight.svg
|IconL=Draft_Downgrade.svg
|IconR=Draft_Draft2Sketch.svg
|IconC=Workbench_Draft.svg
|IconC=Workbench_Draft.svg
|IconR=Draft_AddPoint.svg
}}
}}


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

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

Latest revision as of 07:41, 10 April 2024

Draft WireToBSpline

Menu location
Modification → Wire to B-spline
Workbenches
Draft, Arch
Default shortcut
None
Introduced in version
-
See also
Draft Wire, Draft BSpline

Description

The Draft WireToBSpline command converts Draft Wires to Draft BSplines and vice versa.

Converting a wire to a B-spline, and a closed B-spline to a closed wire

Usage

  1. Select a Draft Wire or a Draft BSpline.
  2. There are several ways to invoke the command:
    • Press the Wire to B-spline button.
    • Select the Modification → Wire to B-spline option from the menu.
  3. A new object is created.

Notes

  • The command may result in a closed, self-intersecting Draft Wire or Draft BSpline with a face. Such an object will not display properly in the 3D view. Its DataMake Face property, or its DataClosed property, must be set to false.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To convert a wire to a B-spline, or vice versa, pass the Points property of the source object to the make_bspline method, or respectively the make_wire method, of the Draft module.

Example:

import FreeCAD as App
import Draft

doc = App.newDocument()

p1 = App.Vector(1000, 1000, 0)
p2 = App.Vector(2000, 1000, 0)
p3 = App.Vector(2500, -1000, 0)
p4 = App.Vector(3500, -500, 0)

base_wire = Draft.make_wire([p1, p2, p3, p4])
base_spline = Draft.make_bspline([-p1, -1.3*p2, -1.2*p3, -2.1*p4])

points1 = base_wire.Points
spline_from_wire = Draft.make_bspline(points1)

points2 = base_spline.Points
wire_from_spline = Draft.make_wire(points2)

doc.recompute()