Paraview python中的SaveData未保存文件

2024-09-30 16:36:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用一个stl文件使用Paraview分割stl。我在paraview中使用python跟踪来跟踪该方法

现在,我使用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]vtkdemandrivenpipeline:713 ERR | vtkpvcompositedappipeline(0x556f782fe7c0):算法vtkpolydatanormals(0x556f7a16b2a0)的输入端口0有0个连接,但不是可选的。

如何克服这个错误

任何线索将不胜感激

问候,, Sunag R A


Tags: 文件path代码importinputlibcreatesys
1条回答
网友
1楼 · 发布于 2024-09-30 16:36:08

错误消息意味着mesh176_rightstl是None,因此FindSource没有找到任何内容。源名称正确吗?数据加载是否正确

出现错误时,脚本将停止,并且不会调用SaveData。但它的语法是正确的

测试stl编写器的最少代码:

s = Sphere()
SaveData('sphere.stl', proxy = s, FileType='Ascii')

它使用ParaView 5.9正确生成stl文件

编辑

你应该取消这行的注释

#threshold1.Scalars = ['POINTS', 'RegionId']

因为直到您请求(例如使用SaveData)时才执行管道,所以在创建阈值时找不到默认数组

相关问题 更多 >