0

古いプロジェクトの自動化スクリプトを書いていますがpvpythonParaview 3.98.1の助けが必要です。このバージョンの機能SaveData()は存在しません。ここでその実装を見つけて、自分のコードに移動しました。ファイルを ASCII として保存するにはどうすればよいですか? のように呼び出すとSaveData(filename, proxy=px, FileType='Ascii')、ファイルがバイナリとして保存されます (厄介な動作)。

vtkスクリプト パイプラインのコードの一部が非常に特殊なファイルを処理するため、このバージョンが必要です。最新バージョンの機能を使用するSaveData()と、最終ファイルに異なるメタデータが作成され、それらを処理すると結果が破棄されます。現時点では、すべてのコードを変更するよりも古いバージョンの Paraview を使用する方が簡単です。

編集

ウェブサイトは現在機能していませんが、昨日のことです。多分それは内部の問題ですか?とにかく、コードは以下に添付されています。

# -----------------------------------------------------------------------------

def SetProperties(proxy=None, **params):
    """Sets one or more properties of the given pipeline object. If an argument
    is not provided, the active source is used. Pass a list of property_name=value
    pairs to this function to set property values. For example::

        SetProperties(Center=[1, 2, 3], Radius=3.5)
    """
    if not proxy:
        proxy = active_objects.source
    properties = proxy.ListProperties()
    for param in params.keys():
        pyproxy = servermanager._getPyProxy(proxy)
        pyproxy.__setattr__(param, params[param])

# -----------------------------------------------------------------------------

def CreateWriter(filename, proxy=None, **extraArgs):
    """Creates a writer that can write the data produced by the source proxy in
        the given file format (identified by the extension). If no source is
        provided, then the active source is used. This doesn't actually write the
        data, it simply creates the writer and returns it."""
    if not filename:
        raise RuntimeError ("filename must be specified")
    session = servermanager.ActiveConnection.Session
    writer_factory = servermanager.vtkSMProxyManager.GetProxyManager().GetWriterFactory()
    if writer_factory.GetNumberOfRegisteredPrototypes() == 0:
        writer_factory.UpdateAvailableWriters()
    if not proxy:
        proxy = GetActiveSource()
    if not proxy:
        raise RuntimeError ("Could not locate source to write")
    writer_proxy = writer_factory.CreateWriter(filename, proxy.SMProxy, proxy.Port)
    writer_proxy.UnRegister(None)
    pyproxy = servermanager._getPyProxy(writer_proxy)
    if pyproxy and extraArgs:
        SetProperties(pyproxy, **extraArgs)
    return pyproxy

# -----------------------------------------------------------------------------

def SaveData(filename, proxy=None, **extraArgs):
    """Save data produced by 'proxy' in a file. If no proxy is specified the
    active source is used. Properties to configure the writer can be passed in
    as keyword arguments. Example usage::

        SaveData("sample.pvtp", source0)
        SaveData("sample.csv", FieldAssociation="Points")
    """
    writer = CreateWriter(filename, proxy, **extraArgs)
    if not writer:
        raise RuntimeError ("Could not create writer for specified file or data type")
    writer.UpdateVTKObjects()
    writer.UpdatePipeline()
    del writer
    
# -----------------------------------------------------------------------------
4

1 に答える 1