Jump to content
  • 0

Vectorscript external libraries


SimA

Question

Hello

 

I'm trying to use the following .py code in Vectorscript as a Python script. Compiling works. The application fails and the libraries are referenced. The libraries are there. what do i have to do?

 

Thanks for your help!

 

 

 

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

def create_turtle_shell(mesh_points, num_layers=5, layer_thickness=0.1):
    """
    Erstellt schalenartige Elemente um die Hülle des 3D-Objekts.

    Parameters:
    - mesh_points: Eine Nx3-NumPy-Array mit den Koordinaten der Meshpunkte.
    - num_layers: Die Anzahl der Schichten.
    - layer_thickness: Die Dicke jeder Schicht.

    Returns:
    - turtle_shell: Eine Poly3DCollection, die die schalenartigen Elemente repräsentiert.
    """
    turtle_shell = []

    for i in range(num_layers):
        shell_points = mesh_points * (1 + i * layer_thickness)
        hull_faces = create_convex_hull(shell_points)
        turtle_shell.append(hull_faces)

    return turtle_shell

def create_convex_hull(points):
    """
    Erstellt die konvexe Hülle für eine Menge von Punkten.

    Parameters:
    - points: Eine Nx3-NumPy-Array mit den Koordinaten der Punkte.

    Returns:
    - hull_faces: Eine Poly3DCollection, die die konvexe Hülle repräsentiert.
    """
    from scipy.spatial import ConvexHull

    hull = ConvexHull(points)
    hull_faces = Poly3DCollection([hull.points[face] for face in hull.simplices], alpha=0.2)

    return hull_faces

# Beispiel: Erzeuge zufällige 3D-Punkte
np.random.seed(42)
mesh_points = np.random.rand(100, 3)

# Erzeuge die schalenartigen Elemente
turtle_shell = create_turtle_shell(mesh_points)

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

for layer in turtle_shell:
    ax.add_collection3d(layer)

ax.scatter(mesh_points[:, 0], mesh_points[:, 1], mesh_points[:, 2], c='r', marker='o')

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
 

Link to comment

1 answer to this question

Recommended Posts

  • 0

My libraries are stored under this path. Could this be a problem? The library is updated.

 

/Users/"meinname"/opt/miniconda3/lib/python3.8/site-packages

 

 

Package                 Version

----------------------- -------------------

brotlipy                0.7.0

certifi                 2023.11.17

cffi                    1.16.0

chardet                 5.2.0

charset-normalizer      3.3.2

click                   8.1.7

conda                   4.9.2

conda-package-handling  2.2.0

conda_package_streaming 0.9.0

contourpy               1.1.1

cryptography            41.0.7

cycler                  0.12.1

enum-compat             0.0.3

fonttools               4.47.0

future                  0.18.3

idna                    3.6

importlib-resources     6.1.1

kiwisolver              1.4.5

matplotlib              3.7.4

numpy                   1.24.4

packaging               23.2

paho-mqtt               1.6.1

pandas                  2.0.3

pexpect                 4.9.0

pillow                  10.2.0

pip                     23.3.2

pip-autoremove          0.10.0

ptyprocess              0.7.0

pycosat                 0.6.6

pycparser               2.21

pyOpenSSL               23.3.0

pyparsing               3.1.1

pyserial                3.5

PySocks                 1.7.1

python-dateutil         2.8.2

pytz                    2023.3.post1

requests                2.31.0

robodk                  5.6.7

robopython              1.0.4

ruamel.yaml             0.18.5

ruamel.yaml.clib        0.2.8

ruamel-yaml-conda       0.15.80

scipy                   1.10.1

setuptools              49.6.0.post20210108

six                     1.16.0

tqdm                    4.66.1

tzdata                  2023.4

urllib3                 2.1.0

wheel                   0.36.2

zipp                    3.17.0

zstandard               0.22.0

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...