Arch OBJ/pl: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updating to match new version of source page)
Line 5: Line 5:
|[[Arch_Module/pl|Środowisko pracy Arch]]}}
|[[Arch_Module/pl|Środowisko pracy Arch]]}}


== Description ==

<div class="mw-translate-fuzzy">
Dodatkowo oprócz standardowego eksportera FreeCAD [http://en.wikipedia.org/wiki/Wavefront_.obj_file OBJ], [[Arch Module/pl|Środowisko pracy Arch]] posiada alternatywny eksporter, który eksportuje koplanarne powierzchnie jako całe powierzchnie OBJ, zamiast triangulacji obiektów opartych na [[Part Module/pl|kształtach]], jak to robi standardowy eksporter.
Dodatkowo oprócz standardowego eksportera FreeCAD [http://en.wikipedia.org/wiki/Wavefront_.obj_file OBJ], [[Arch Module/pl|Środowisko pracy Arch]] posiada alternatywny eksporter, który eksportuje koplanarne powierzchnie jako całe powierzchnie OBJ, zamiast triangulacji obiektów opartych na [[Part Module/pl|kształtach]], jak to robi standardowy eksporter.
</div>

== Exporting without GUI ==

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

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.

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

== More information ==

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


==Poradniki==
==Poradniki==
Line 15: Line 51:
|[[Arch JSON/pl|JSON]]
|[[Arch JSON/pl|JSON]]
|[[Arch_Module/pl|Środowisko pracy Arch]]}}
|[[Arch_Module/pl|Środowisko pracy Arch]]}}



{{Arch Tools navi{{#translation:}}}}
{{Arch Tools navi{{#translation:}}}}

{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
[[Category:File Formats{{#translation:}}]]
[[Category:File Formats{{#translation:}}]]

Revision as of 18:55, 10 September 2020

Description

Dodatkowo oprócz standardowego eksportera FreeCAD OBJ, Środowisko pracy Arch posiada alternatywny eksporter, który eksportuje koplanarne powierzchnie jako całe powierzchnie OBJ, zamiast triangulacji obiektów opartych na kształtach, jak to robi standardowy eksporter.

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

Poradniki