Arch OBJ: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
No edit summary
(6 intermediate revisions by 3 users not shown)
Line 2: Line 2:
<translate>
<translate>
<!--T:5-->
<!--T:5-->
{{Docnav
{{docnav|[[Arch DAE|DAE]]|[[Arch JSON|JSON]]|[[Arch_Module|Arch Module]]}}
|[[Arch_DAE|DAE]]
|[[Arch_JSON|JSON]]
|[[Arch_Module|Arch Module]]
}}

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


<!--T:1-->
<!--T:1-->
Additionally to the standard FreeCAD [http://en.wikipedia.org/wiki/Wavefront_.obj_file OBJ] exporter, the [[Arch Module]] features an alternative exporter that exports coplanar faces as whole OBJ faces, instead of triangulating [[Part Module|Shape]]-based objects, like the standard exporter does.
Additionally to the standard FreeCAD [http://en.wikipedia.org/wiki/Wavefront_.obj_file OBJ] exporter, the [[Arch_Module|Arch Workbench]] features an alternative exporter that exports coplanar faces as whole OBJ faces, instead of triangulating [[Shape|Shape]]-based objects, like the standard exporter does.

== Exporting without GUI == <!--T:9-->

<!--T:10-->
Exporting without the graphical interface is possible from the command line, using the [[Mesh_Workbench|Mesh Workbench]] exporter only.

<!--T:11-->
In this example, a STEP file is imported, the colors of the [[Shape|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.

</translate>
{{Code|code=
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")
}}
<translate>

== More information == <!--T:12-->

<!--T:13-->
* [https://forum.freecadweb.org/viewtopic.php?f=8&t=37452 Convert STEP to Wavefront OBJ with colors of faces]


==Tutorials== <!--T:3-->
==Tutorials== <!--T:3-->
Line 12: Line 55:


<!--T:4-->
<!--T:4-->
{{Docnav
{{docnav|[[Arch DAE|DAE]]|[[Arch JSON|JSON]]|[[Arch_Module|Arch Module]]}}
|[[Arch_DAE|DAE]]

|[[Arch_JSON|JSON]]

|[[Arch_Module|Arch Module]]
<!--T:6-->
}}
{{Arch Tools navi}}


<!--T:7-->
{{Userdocnavi}}
</translate>
</translate>
{{Arch Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
[[Category:File Formats{{#translation:}}]]

Revision as of 08:55, 17 September 2020

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