[Python] Is there a way to convert wireframe models to solid, watertight exports for FEA

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying to convert this wireframe into a solid 3d model for finite element analysis and I'm just lost. Here's the code and an image of the wireframe:

    import numpy as np
    import pyvoro
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d.art3d import Line3DCollection

    # Initialize random number generator
    rng = np.random.default_rng()

    # Create a set of points in 3D
    points = rng.uniform(size=(30,3))

    # Compute the Voronoi tessellation
    voronoi = pyvoro.compute_voronoi(points, [[0,1],[0,1],[0,1]], 15)

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    # Loop through each Voronoi cell and plot only edges
    for vcell in voronoi:
    vertices = np.array(vcell['vertices'])
    edges = []

    # Extract edges from faces
    for face in vcell['faces']:
    face_vertices = vertices[np.array(face['vertices'])]
    for i in range(len(face_vertices)):
    edge = [face_vertices, face_vertices[(i+1) % len(face_vertices)]]
    edges.append(edge)

    # Convert to a Line3DCollection and add to plot
    wireframe = Line3DCollection(edges, colors='black', linewidths=0.5)
    ax.add_collection3d(wireframe)

    # Adjust plot limits
    ax.set_xlim(0, 1)
    ax.set_ylim(0, 1)
    ax.set_zlim(0, 1)

    plt.show()


    [​IMG]

    Continue reading...

Compartilhe esta Página