Draft OCA/cs: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{docnav|[[Draft_SVG|SVG]]|[[Draft_DAT|Airfoil Data Format .DAT]]|[[Draft_Module|Draft Module]]|IconC=Workbench_Draft.svg}}


{{Docnav
{{GuiCommand
|[[Draft_SVG|Scalable Vector Graphics .SVG]]
|Name=Draft OCA
|[[Draft_DAT|Airfoil Data Format .DAT]]
|MenuLocation=File → Export → Open CAD format (*.oca)
|Workbenches=[[Draft Workbench|Draft]]
|[[Draft_Workbench|Draft]]
|IconL=
|Shortcut=Ctrl+E
|IconR=
|SeeAlso=[[Draft SVG]], [[Draft DXF]]
|IconC=Workbench_Draft.svg
|Empty=1
}}
}}


{{TOCright}}
== Description ==
This function imports OCA/GCAD files. The [http://groups.google.com/group/open_cad_format OCA file format] is community effort to create a free, simple and open CAD file format.


==Description==
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.


Draft OCA is a software module used by the [[File:Std_Open.svg|24px]] [[Std_Open|Std Open]], [[File:Std_Import.svg|24px]] [[Std_Import|Std Import]] and [[File:Std_Export.svg|24px]] [[Std_Export|Std Export]] commands to handle the [http://groups.google.com/group/open_cad_format OCA file format].
== Opening ==


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.
The following OCA objects get imported at the moment:

==Importing==

The following OCA objects can be imported:
* Lines
* Lines
* Arcs and Circles
* Arcs and Circles
* Closed areas
* Closed areas


== Importing ==
==Exporting==
Works the same way as opening but places the objects in the active document instead of creating a new one.


The following FreeCAD objects can be exported:
== Exporting ==
Objects that can be exported at the moment:
* Lines and wires (polylines)
* Lines and wires (polylines)
* Arcs and circles
* Arcs and circles
* Faces
* Faces


== Preferences ==
==Preferences==
The following parameters can be specified in the [[Draft Preferences]] tab, {{MenuCommand|Edit → Preferences → Draft}}:
* Import closed areas or not


See [[Import_Export_Preferences|Import Export Preferences]].
== Scripting ==

{{Emphasis|See also:}} [[Draft API]] and [[FreeCAD Scripting Basics]].
==Scripting==

See also: [https://freecad.github.io/SourceDoc/ Autogenerated API documentation] and [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]].

To export objects to OCA use the {{incode|export}} method of the importOCA module.


You can export elements to OCA by using the following function:
{{Code|code=
{{Code|code=
importOCA.export(exportList, filename)
importOCA.export(exportList, filename)
}}
}}

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


Example:
Example:

{{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")
}}
}}



<div class="mw-translate-fuzzy">
<div class="mw-translate-fuzzy">
Line 67: Line 73:
{{Draft Tools navi{{#translation:}}}}
{{Draft Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
[[Category:File Formats{{#translation:}}]]
{{clear}}

Latest revision as of 08:04, 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")