Draft OCA: Difference between revisions

From FreeCAD Documentation
(Added "In progress".)
(Marked this version for translation)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Page in progress}}
<languages/>
<languages/>
<translate>
<translate>
Line 5: Line 4:
<!--T:13-->
<!--T:13-->
{{Docnav
{{Docnav
|[[Draft_SVG|SVG]]
|[[Draft_SVG|Scalable Vector Graphics .SVG]]
|[[Draft_DAT|Airfoil Data Format .DAT]]
|[[Draft_DAT|Airfoil Data Format .DAT]]
|[[Draft_Module|Draft Module]]
|[[Draft_Workbench|Draft]]
|IconL=
|IconL=
|IconR=
|IconR=
Line 13: Line 12:
}}
}}


</translate>
<!--T:7-->
{{TOCright}}
{{GuiCommand
<translate>
|Name=Draft OCA
|MenuLocation=-
|Workbenches=[[Draft Workbench|Draft]]
|Shortcut=-
|SeeAlso=-
|Empty=1
}}


==Description== <!--T:8-->
==Description== <!--T:8-->
Line 29: Line 22:


<!--T:9-->
<!--T:9-->
The OCA file format is community effort to create a free, simple and open CAD file format. OCA is largely based on the GCAD file format generated from [http://www.gcad3d.org/ gCAD3D]. Both formats can be imported in FreeCAD, and the OCA files exported by FreeCAD can be opened in gCAD3D.
The OCA file format is a community effort to create a free, simple and open CAD file format. OCA is largely based on the GCAD file format generated from [http://www.gcad3d.org/ gCAD3D]. Both formats can be imported in FreeCAD, and the OCA files exported by FreeCAD can be opened in gCAD3D.


==Importing== <!--T:1-->
==Importing== <!--T:1-->
Line 50: Line 43:


<!--T:18-->
<!--T:18-->
For more information see: [[Import_Export_Preferences|Import Export Preferences]].
See [[Import_Export_Preferences|Import Export Preferences]].


==Scripting== <!--T:10-->
==Scripting== <!--T:19-->

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


<!--T:11-->
<!--T:11-->
You can export elements to OCA by using the following function:
To export objects to OCA use the {{incode|export}} method of the importOCA module.

</translate>
</translate>
{{Code|code=
{{Code|code=
Line 62: Line 58:
}}
}}
<translate>
<translate>

<!--T:20-->
* For the Windows OS: use a {{FileName|/}} (forward slash) as the path separator in {{Incode|filename}}.


<!--T:12-->
<!--T:12-->
Example:
Example:

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


doc = App.newDocument()
p1 = FreeCAD.Vector(0, 0, 0)
p2 = FreeCAD.Vector(1000, 1000, 0)
p3 = FreeCAD.Vector(2200, 1500, 0)
p4 = FreeCAD.Vector(2500, -100, 0)


obj1 = Draft.makeWire([p1, p2, p3, p4])
polygon1 = Draft.make_polygon(3, radius=500)
obj2 = Draft.makeWire([p1, -2.3*p2, -0.8*p3, -1.8*p4])
polygon2 = Draft.make_polygon(5, radius=1500)


doc.recompute()
objects = [obj1, obj2]


objects = [polygon1, polygon2]
importOCA.export(objects, "/home/user/Pictures/myfile.oca")
importOCA.export(objects, "/home/user/Pictures/myfile.oca")
}}
}}
Line 86: Line 86:
<!--T:6-->
<!--T:6-->
{{Docnav
{{Docnav
|[[Draft_SVG|SVG]]
|[[Draft_SVG|Scalable Vector Graphics .SVG]]
|[[Draft_DAT|Airfoil Data Format .DAT]]
|[[Draft_DAT|Airfoil Data Format .DAT]]
|[[Draft_Module|Draft Module]]
|[[Draft_Workbench|Draft]]
|IconL=
|IconL=
|IconR=
|IconR=
Line 98: Line 98:
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
[[Category:File Formats{{#translation:}}]]
[[Category:File Formats{{#translation:}}]]
{{clear}}

Latest revision as of 08:03, 15 September 2021

Description

Draft OCA is a software module used by the Std Open, Std Import and Std Export commands to handle the OCA file format.

The OCA file format is a community effort to create a free, simple and open CAD file format. OCA is largely based on the GCAD file format generated from gCAD3D. Both formats can be imported in FreeCAD, and the OCA files exported by FreeCAD can be opened in gCAD3D.

Importing

The following OCA objects can be imported:

  • Lines
  • Arcs and Circles
  • Closed areas

Exporting

The following FreeCAD objects can be exported:

  • Lines and wires (polylines)
  • Arcs and circles
  • Faces

Preferences

See Import Export Preferences.

Scripting

See also: Autogenerated API documentation and FreeCAD Scripting Basics.

To export objects to OCA use the export method of the importOCA module.

importOCA.export(exportList, filename)
  • For the Windows OS: use a / (forward slash) as the path separator in filename.

Example:

import FreeCAD as App
import Draft
import importOCA

doc = App.newDocument()

polygon1 = Draft.make_polygon(3, radius=500)
polygon2 = Draft.make_polygon(5, radius=1500)

doc.recompute()

objects = [polygon1, polygon2]
importOCA.export(objects, "/home/user/Pictures/myfile.oca")