API Documentation

class pyofx.Jobs(dllname=None)[source]

Python interface to Distributed OrcaFlex

>>> from pyofx import Jobs
>>> j = Jobs(r"\\network\path\to\OrcFxAPI.dll")

Methods:

add(filepath, variables=None)

Adds an orcaflex file to the list of jobs with optional variables object.

>>> j.add(r"\\network\folder\Hs=2.2m_model.dat", {'Hs':'2.2m'})

run(wait=False)

Submits jobs to Distributed Orcaflex. If wait is True it will not return unitll all jobs have completed.

>>> j.run(True)
>>> print "All jobs finished" # This won't print unitll the simulations are complete.
add_file(filepath, variables=None)[source]

Adds a filepath (must be network path or a mapped drive) to the list of jobs to run. Optionally takes a variables object to represent information about the job.

list()[source]

a generator for all the jobs on the Distributed Orcaflex Server. Each job will be returned as a dictionary with the following keys: Job ID, Simulation file name including full path, Owner, Status, Start Time, Completed Time, Name of machine last run on, IP address of machine last run on, AutoSave interval, OrcFxAPI DLL version and Status string.

run(wait=False, statics=False)[source]

Submit the jobslist to Distributed Orcaflex. If wait=True then wait until the jobs complete to return. To run statics only use statics=True

class pyofx.Model(*args, **kwargs)[source]

Wrapper around OrcFxAPI.Model to add extra functionality.

  1. added path attribute so the location of the model on the disc can be found from:
>>> model = Model(r"C:\path o\data_file.dat")
>>> model.path
"C:\path    o\data_file.dat"

2. added a model_name attribute (added in v0.0.9) of the file name without path or extensions:

>>> model = Model(r"C:\path o\data_file.dat")
>>> model.model_name
"data_file"

3. added the open method. This will open the model in the OrcaFlex GUI, if the model does not exist on disc then a windows temp file will be created. Won’t return until the OrcaFlex.exe instance is closed.

>>> model = Model()
>>> model.open() # Opens a temp file in OrcaFlex.exe

4. added objects_of_type() to return a list of objects in the model of a certain types/ e.g. model.objects_of_type(‘Line’)

>>> model = Model()
>>> model.CreateObject(otVessel, 'Bigger Boat')
>>> for v in model.objects_of_type('Vessel'):
...     print v.name
"Bigger Boat"
  1. added attribute lines, shortcut to objects_of_type(‘Line’)
  2. added attribute vessels, shortcut to objects_of_type(‘Vessel’)
  3. added attribute six_d_buoys, shortcut to objects_of_type(‘6DBuoy’)
lines[source]

all the objects of type otLine

objects_of_type(type_name, test=None)[source]

list of all objects in model with typeName equal to type_name

option to add a test function to further filter the list

six_d_buoys[source]

all the objects of type ot6DBuoy

vessels[source]

all the objects of type otLine

class pyofx.Models(directories, filetype='dat', subdirectories=False, return_model=True, filter_function=None, failed_function=None, virtual_logging=False)[source]

a generator which yields OrcaFlex files in directories.

Suppose we have saved some simulations in C:UsersUserProjectOrcaFlex, to iterate over all those simulations we can use:

>>> for model in Models(r"C:\Users\User\Project\OrcaFlex"):
...    print model
<pyofx.Model object at 0x00000000031B6DD8>
<pyofx.Model object at 0x00000000031B6E80>

Note that in the above example the generator yields Model objects of the .dat files. To return the path to the file rather than the Model object we can pass return_model=False and to return .sim file filetype=”sim”

There are various other options as detailed in the api_docs_:

exception pyofx.OFXError[source]

Branded errors so we know it’s our fault

pyofx.buoy_drawing(size, ofx_object=None)[source]

scale the standard 6D buoy cuboid to width and height of size (the default size is 6m)

If ofx_object is provided then the object drawing will be changed otherwise the correct array is copied to the clipboard to paste into the 6D Buoy drawing table.

pyofx.check_licence()[source]

true if a licence can be found

Useful for polling to wait for a free licence. See examples.py

pyofx.dat_sim_paths(directory, name, yml=False)[source]

Tuple containing full .dat (or .yml if yml=True) and .sim filepath for filename name in directory.

pyofx.gamma_dnv(h_s, t_p)[source]

the peak shape parameter (gamma) according to DNV-RP-H103 2.2.6.9

pyofx.get_modes(model, line, from_mode=-1, to_mode=100)[source]

List of (Mode Number, Modal Period, Modal Frequency) tuples for modal analysis of lines. Check specific range of modes with from_mode and to_mode.

pyofx.get_unc_path(local_name)[source]

the UNC path of a mapped drive.

Useful because some distributed OrcaFlex versions want only networked filepaths. Returns None if the drive is not mapped (e.g. C:)

pyofx.vessel_drawing(length, depth, beam, bow_scale=(0.9, 0.95), vessel_type=None)[source]

scale the default OrcaFlex vessel type drawing

Given a vessel of specifed length, depth and beam. Bow shape determined by the bow_scale parameter.

if an OrcaFlexObject with typeName=otVesselType is passed as the vessel_type parameter then the drawing will be applied otherwise the correct array is copied to the clipboard to paste into the vessel type drawing table.

Previous topic

Welcome to pyofx’s documentation!

This Page