如何解决Paraview python 中的 SaveData 不保存文件 编辑
我使用一个 stl 文件使用 Paraview 拆分 stl。我在paraview中使用python trace跟踪了该方法。
现在,我使用python中的代码来运行它。它运行完美,但它不会根据需要保存分割的网格。该代码根据从 paraview 获得的跟踪使用。下面是使用 SaveData 保存文件的代码片段。如何保存stl文件?
import sys #sys- append path
import numpy as np
ParaViewBuildPath = "/home/ParaView-5.7.0/"
sys.path.append(ParaViewBuildPath + "lib/")
sys.path.append(ParaViewBuildPath + "lib/python3.7/site-packages")
sys.path.append(ParaViewBuildPath + "lib/python3.7/site-packages/vtkmodules")
from paraview.simple import *
import vtk
# find source
mesh176_rightstl = FindSource('mesh176_right.stl')
generateSurfaceNormals1 = GenerateSurfaceNormals(Input=mesh176_rightstl)
# Properties modified on generateSurfaceNormals1
generateSurfaceNormals1.FeatureAngle = 15.0
# create a new 'Connectivity'
connectivity1 = Connectivity(Input=generateSurfaceNormals1)
# create a new 'Threshold'
threshold1 = Threshold(Input=connectivity1)
#threshold1.Scalars = ['POINTS','RegionId']
# Properties modified on threshold1
threshold1.ThresholdRange = [10.0,982.0]
# create a new 'Extract Surface'
extractSurface1 = ExtractSurface(Input=threshold1)
# save data
SaveData('surf176.stl',proxy=extractSurface1,FileType='Ascii')
我已经从“generateSurfaceNormals1”行中解决了我面临的错误。
[paraview]vtkDemandDrivenPipeline:713 ERR| vtkPVCompositeDataPipeline (0x556f782fe7c0):算法 vtkPPolyDataNormals(0x556f7a16b2a0) 的输入端口 0 有 0 个连接但不是可选的。
如何克服这个错误?
任何线索将不胜感激。
问候, Sunag R A.
解决方法
错误消息意味着 mesh176_rightstl
为 None,因此 FindSource
找不到任何内容。源名称是否正确?数据是否正确加载?
当出现错误时,脚本停止并且不调用 SaveData
。但它的语法是正确的。
测试stl编写器的最少代码:
s = Sphere()
SaveData('sphere.stl',proxy = s,FileType='Ascii')
使用 ParaView 5.9 正确生成 stl 文件
编辑
您应该取消注释该行
#threshold1.Scalars = ['POINTS','RegionId']
因为在您要求之前不会执行管道(例如使用 SaveData),所以在您创建阈值时找不到默认数组。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。