Example #1
0
 def loadState(self, state_file):
     """
     Load a state file and return the list of view ids
     """
     simple.LoadState(state_file)
     ids = []
     for view in simple.GetRenderViews():
         ids.append(view.GetGlobalIDAsString())
     return ids
Example #2
0
def process_pvsm(state, dest):
    simple.LoadState(str(state))
    gen_screenshot(state, dest)
def main():
    import sys  # to get command line args
    import argparse  # to parse options for us and print a nice help message

    argv = sys.argv

    if __file__ in argv:
        argv = argv[argv.index(__file__) + 1:]  # get all args after __file__

    usage_text = "Run ParaView in background mode with this script:"
    usage_text += "  pvpython " + __file__ + " [options]"

    parser = argparse.ArgumentParser(description=usage_text)

    parser.add_argument("-i",
                        "--input",
                        dest="input",
                        metavar='FILE',
                        required=True,
                        help="Input path contained in a text file.")
    parser.add_argument("-p",
                        "--plugin",
                        dest="plugin",
                        metavar='FILE',
                        required=True,
                        help="Path to FA-plugin (libFacetAnalyser.so).")
    parser.add_argument("-o",
                        "--output",
                        dest="output",
                        metavar='FILE',
                        required=True,
                        help="Output name to export X3D")

    args = parser.parse_args(argv)

    if not argv:
        parser.print_help()
        return

    if not args.input:
        print('Need an input file')
        parser.print_help()
        sys.exit(1)

    if not args.plugin:
        print('Need a plugin file')
        parser.print_help()
        sys.exit(1)

    if not args.output:
        print('Need an output file')
        parser.print_help()
        sys.exit(1)

    pvs.LoadPlugin(args.plugin, remote='False')

    ## read pvsm
    pvs.LoadState(args.input)

    rv = pvs.GetRenderView()

    exporters = pvs.servermanager.createModule("exporters")
    # dir(exporters) # lists export modules: CSVExporter, CinemaExporter, GL2PSContextViewExporterBase, GL2PSContextViewExporterEPS, GL2PSContextViewExporterPDF, GL2PSContextViewExporterPS, GL2PSContextViewExporterSVG, GL2PSExporterBase, GL2PSRenderViewExporterBase, GL2PSRenderViewExporterEPS, GL2PSRenderViewExporterPDF, GL2PSRenderViewExporterPS, GL2PSRenderViewExporterSVG, POVExporter, VRMLExporter, WebGLExporter, X3DExporter, X3DExporterBinary

    exporter = exporters.X3DExporter(FileName=args.output)
    exporter.SetView(rv)
    exporter.Write()

    ## output for ctest for regex-check because script itself fails with:
    ## Inconsistency detected by ld.so: dl-close.c: _dl_close: Assertion `map->l_init_called' failed!
    ## this happens even without qt-at-spi: http://www.cfd-online.com/Forums/openfoam-paraview/128851-pvpython-ubuntu-deb-package.html
    if os.path.isfile(args.output):
        print("Export succeded")
    else:
        print("Export failed")
Example #4
0
                    required=True)
parser.add_argument(
    "--extracts-dir",
    type=str,
    help=
    "path to directory where to make the Catalyst script save generated extracts",
    required=True)
parser.add_argument("--pvsm",
                    type=str,
                    help="pvsm state file to load",
                    required=True)

args = parser.parse_args()

from paraview import simple, catalyst
simple.LoadState(args.pvsm)

options = catalyst.Options()
options.DataExtractsOutputDirectory = args.extracts_dir
options.ImageExtractsOutputDirectory = args.extracts_dir

# TODO: add a 'simple' version for this, we don't want users to
# import anything from 'detail' and hence we don't want that in a demo
# script.
import os, os.path
# remove output if it exists
if os.path.exists(args.output):
    print("removing existing output file:", args.output)
    os.remove(args.output)

from paraview.detail.catalyst_export import save_catalyst_package_as_zip