Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymesh.virtual_entities() returns incorrect Face3d #589

Closed
mozman opened this issue Dec 17, 2021 · 2 comments
Closed

Polymesh.virtual_entities() returns incorrect Face3d #589

mozman opened this issue Dec 17, 2021 · 2 comments

Comments

@mozman
Copy link
Owner

mozman commented Dec 17, 2021

Originally posted by chibai December 17, 2021
I'm trying to extract the basic element from a polyline(polyface)
But the vertices of the entity make me crazy
test.zip
test

from ezdxf import recover
from ezdxf.addons.drawing import matplotlib
# Exception handling left out for compactness:
doc, auditor = recover.readfile('test.dxf')
if not auditor.has_errors:
    matplotlib.qsave(doc.modelspace(), 'test.png')
for entity in doc.modelspace():
    if entity.dxf.handle == 'F6AC':
        e = list(entity.virtual_entities())[0]
        print(e.wcs_vertices())
skipped entity 3DFACE(#EC29). Reason: "invisible"
skipped entity 3DFACE(#EC2A). Reason: "invisible"
skipped entity 3DFACE(#EC2B). Reason: "invisible"
[Vec3(59416.31455091119, 21790.91531877725, 0.0), Vec3(59361.25307228302, 21813.84830555742, 0.0), Vec3(59380.16605928067, 21806.95449032696, 0.0), Vec3(0.0, 0.0, 0.0)]

The Vec3(0, 0, 0) if definitely not belong to the entity!

@mozman mozman changed the title Polymesh.virtual_entites() returns incorrect Face3d Polymesh.virtual_entities() returns incorrect Face3d Dec 17, 2021
mozman added a commit that referenced this issue Dec 17, 2021
Returns two identical vertices at the end for triangle faces,
this will be fixed in the next commit.
mozman added a commit that referenced this issue Dec 17, 2021
The 3DFACE entity has ALWAYS 4 vertices, for triangles
the last two vertices are identical.
@mozman
Copy link
Owner Author

mozman commented Dec 17, 2021

Alternative way to get faces and vertices from PolyFaceMesh without creating virtual entities:

docs: https://ezdxf.mozman.at/docs/render/mesh.html

from ezdxf.render import MeshBuilder

...

# sadly the PolyFaceMesh entity is a variant of the POLYLINE entity, like the PolygonMesh entity
for entity in doc.modelspace().query("POLYLINE"):  
    if entity.is_poly_face_mesh:
        print(f"PolyFaceMesh: {str(entity)}")
        builder = MeshBuilder.from_polyface(entity)
        # all vertices used in the mesh independently from the face structure
        print(f"count of vertices: {len(builder.vertices)}")
        # get all mesh faces as list of Vec3() objects in WCS coordinates
        faces = list(builder.faces_as_vertices())
        print(f"count of faces: {len(faces)}")
        for face in faces:
            print(face)

@chibai
Copy link

chibai commented Dec 20, 2021

Thank you!

@mozman mozman closed this as completed Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants