Support PDF-export from Python

This commit is contained in:
Gaute Lindkvist
2020-01-21 12:36:22 +01:00
parent 1133816471
commit e1c1981830
9 changed files with 59 additions and 20 deletions

View File

@@ -45,6 +45,12 @@ message ExportMultiCaseRequest
string gridListFile = 1;
}
enum PlotOutputFormat
{
PNG = 0;
PDF = 1;
}
enum SnapshotType
{
VIEWS = 0;
@@ -54,11 +60,12 @@ enum SnapshotType
message ExportSnapshotsRequest
{
SnapshotType type = 1;
string prefix = 2;
int32 caseId = 3;
int32 viewId = 4;
string exportFolder = 5;
SnapshotType type = 1;
string prefix = 2;
int32 caseId = 3;
int32 viewId = 4;
string exportFolder = 5;
PlotOutputFormat plotOutputFormat = 6;
}
message ExportPropertyRequest

View File

@@ -14,6 +14,7 @@ print("Exporting to: " + export_folder)
for plot in plots:
plot.export_snapshot(export_folder=export_folder)
plot.export_snapshot(export_folder=export_folder, output_format='PDF')
well_log_plot = rips.WellLogPlot.from_pdm_object(plot)
if well_log_plot is not None:
well_log_plot.export_data_as_las(export_folder=export_folder)

View File

@@ -16,18 +16,20 @@ class Plot(PdmObject):
PdmObject.__init__(self, pdm_object.pb2_object(), pdm_object.channel(), pdm_object.project())
self.view_id = pdm_object.get_value("ViewId")
def export_snapshot(self, export_folder='', file_prefix='', ):
def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG'):
""" Export snapshot for the current plot
Arguments:
export_folder(str): The path to export to. By default will use the global export folder
prefix (str): Exported file name prefix
output_format(str): Enum string. Can be 'PNG' or 'PDF'.
"""
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(type='PLOTS',
prefix=file_prefix,
viewId=self.view_id,
exportFolder=export_folder))
exportFolder=export_folder,
plotOutputFormat=output_format))

View File

@@ -224,16 +224,17 @@ class Project(PdmObject):
exportMultiCaseSnapshot=Cmd.ExportMultiCaseRequest(
gridListFile=grid_list_file))
def export_snapshots(self, snapshot_type='ALL', prefix=''):
def export_snapshots(self, snapshot_type='ALL', prefix='', plot_format='PNG'):
""" Export all snapshots of a given type
Arguments:
snapshot_type (str): Enum string ('ALL', 'VIEWS' or 'PLOTS')
prefix (str): Exported file name prefix
plot_format(str): Enum string, 'PNG' or 'PDF'
"""
return self._execute_command(
exportSnapshots=Cmd.ExportSnapshotsRequest(
type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1))
type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1, plotOutputFormat=plot_format))
def export_well_paths(self, well_paths=None, md_step_size=5.0):
""" Export a set of well paths