Difference between revisions of "Arch OBJ/en"

From FreeCAD Documentation
Jump to navigation Jump to search
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 1: Line 1:
 
<languages/>
 
<languages/>
{{docnav|[[Arch DAE|DAE]]|[[Arch JSON|JSON]]|[[Arch_Module|Arch Module]]}}
+
{{Docnav
 +
|[[Arch_DAE|DAE]]
 +
|[[Arch_JSON|JSON]]
 +
|[[Arch_Module|Arch Module]]
 +
}}
  
 
== Description ==
 
== Description ==
Line 42: Line 46:
 
* [[Export_to_STL_or_OBJ|Export to STL or OBJ]]
 
* [[Export_to_STL_or_OBJ|Export to STL or OBJ]]
  
{{docnav|[[Arch DAE|DAE]]|[[Arch JSON|JSON]]|[[Arch_Module|Arch Module]]}}
+
{{Docnav
 +
|[[Arch_DAE|DAE]]
 +
|[[Arch_JSON|JSON]]
 +
|[[Arch_Module|Arch Module]]
 +
}}
  
 
{{Arch Tools navi{{#translation:}}}}
 
{{Arch Tools navi{{#translation:}}}}
 
{{Userdocnavi{{#translation:}}}}
 
{{Userdocnavi{{#translation:}}}}
 
[[Category:File Formats{{#translation:}}]]
 
[[Category:File Formats{{#translation:}}]]

Revision as of 18:42, 17 September 2020

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎polski • ‎português do Brasil • ‎čeština • ‎русский
Arrow-left.svg Previous: DAE
Next: JSON Arrow-right.svg

Description

Additionally to the standard FreeCAD OBJ exporter, the Arch Workbench features an alternative exporter that exports coplanar faces as whole OBJ faces, instead of triangulating Shape-based objects, like the standard exporter does.

Exporting without GUI

Exporting without the graphical interface is possible from the command line, using the Mesh Workbench exporter only.

In this example, a STEP file is imported, the colors of the Shape are saved, then a mesh is created from it, the colors of the original object are re-applied to the faces of the new mesh, which is then exported to OBJ format. Since this is done with the Mesh Workbench, the result is a triangulated mesh.

import Mesh
import MeshPart
import Import

data = Import.open("example.stp")
shape = data[0][0].Shape
shape_colors = data[0][1]

mesh = MeshPart.meshFromShape(Shape=shape, LinearDeflection=0.1, Segments=True)

face_colors = [(0, 0, 0)] * mesh.CountFacets

for i in range(mesh.countSegments()):
    color = shape_colors[i]
    segm = mesh.getSegment(i)
    for j in segm:
        face_colors[j] = color

mesh.write(Filename="new_example.obj", Material=face_colors, Format="obj")

More information

Tutorials

Arrow-left.svg Previous: DAE
Next: JSON Arrow-right.svg