Arch OBJ/fr: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
No edit summary
Line 4: Line 4:
== Description ==
== Description ==


En plus de l'exportateur standard FreeCAD '''[http://fr.wikipedia.org/wiki/Objet_3D_(format_de_fichier) .OBJ]''', l'[[Arch_Module/fr|atelier Arch]] dispose d'une solution alternative d'exportation qui exporte les faces coplanaires comme des faces OBJ entières, au lieu de trianguler les objets basés sur les [[Shape/fr|Shape]], comme le fait l'exportateur standard.
<div class="mw-translate-fuzzy">
En plus de la norme d'exportation FreeCAD '''[http://fr.wikipedia.org/wiki/Objet_3D_(format_de_fichier) .OBJ]''',
le [[Arch Module/fr|module Arch]] dispose d'une solution alternative d'exportation, qui exporte les faces coplanaires des faces comme faces '''.OBJ''', au lieu de la triangulation [[Part Module|Shape (forme)]] des objets de base, comme le fait l'exportateur standard.
</div>


== Exporting without GUI ==
== Exporting without GUI ==

Revision as of 08:50, 17 September 2020

Description

En plus de l'exportateur standard FreeCAD .OBJ, l'atelier Arch dispose d'une solution alternative d'exportation qui exporte les faces coplanaires comme des faces OBJ entières, au lieu de trianguler les objets basés sur les Shape, comme le fait l'exportateur standard.

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

Tutoriels