1

我尝试编辑一个 stl 文件。关于这一点,我使用 numpy-stl 读取了 stl 文件。现在,当我尝试拆分其中存在的行时,它向我显示一个错误:

“numpy.ndarray”对象没有属性“split”

如何克服这一点?下面是代码。

import numpy as np
import stl
from stl import mesh


lines = mesh.Mesh.from_file('mesh.stl')
count = 0
for line in lines:
   if line.split()[0] == "solid":
      repl = line.split()[1]
      print(repl)

任何线索将不胜感激。

问候, Sunag R A.

4

2 回答 2

0

只需使用str(line)替代tostring(line)方法

于 2021-08-04T02:29:58.337 回答
0

这是因为您获得了一个应用拆分的 ndarray 对象。

只需在执行之前将其转换为字符串(使用tostring()方法),它就会起作用。

于 2021-03-30T07:23:04.233 回答