以上代码运行报错:TypeError: 'array.array' object is not callable
时间: 2023-07-06 11:30:08 浏览: 204
很抱歉,我之前提供的代码有误。正确的代码如下:
import ezdxf
# 打开DXF文件
doc = ezdxf.readfile("example.dxf")
# 获取模型空间
msp = doc.modelspace()
# 遍历模型空间中的实体
for entity in msp:
# 判断实体类型是否为Spline
if entity.dxftype() == "SPLINE":
# 获取曲线上的所有控制点
control_points = entity.control_points
# 获取曲线上的所有节点
knots = entity.knots()
# 获取节点权重
weights = entity.weights()
# 获取次数
degree = entity.degree
# 获取分段数
num_points = entity.tuple_size()
# 获取插值点
points = entity.approximate(num_points)
# 打印曲线上的所有点
for p in points:
print(f"({p[0]}, {p[1]})")
我之前使用了错误的方法来获取节点,应该使用entity.knots()
方法来获取节点。如果还有其他问题,请随时提问。
相关推荐


















