Oasys.REPORTER.Template class¶
Properties¶
- property Template.path(read only): string¶
Absolute path (without filename) of the
Template
. If the Template is new and has not yet been saved, this property will be empty
- property Template.view: constant¶
Current view type (presentation or design view) for this
Template
. Can be:Reporter.VIEW_DESIGN
orReporter.VIEW_PRESENTATION
Constructor¶
- classmethod Template(filename=Oasys.gRPC.defaultArg)¶
Create a new
Template
. The filename argument is optional. If present it is a file to open
- Parameters:
filename (string) – Optional. Name of template file to open
- Returns:
Template object
- Return type:
dict
Example
To create a new blank Template object
template = Oasys.REPORTER.Template()
Static methods¶
- classmethod Template.GetAll()¶
Get all of the open templates
- Returns:
list of Template objects or None if no open templates
- Return type:
list
Example
To get all of the templates open in REPORTER:
templates = Oasys.REPORTER.Template.GetAll()
- classmethod Template.GetCurrent()¶
Get the currently active template
- Returns:
Template object or None if no active template
- Return type:
dict
Example
To get the current template open in REPORTER:
current_template = Oasys.REPORTER.Template.GetCurrent()
Instance methods¶
- Template.Close()¶
Close a template.
Note that if you call this function for a Template object, the Template data will be deleted, so you should not try to use it afterwards!
- Returns:
no return value
- Return type:
None
Example
To close template data:
data.Close()
- Template.DeletePage(index)¶
Deletes a page from a template
- Parameters:
index (integer) – The index of the page that you want to delete. Note that indices start at 0
- Returns:
No return value
- Return type:
None
Example
To delete the first page of template t:
t.DeletePage(0)
- Template.DeleteTemporaryVariables()¶
Deletes any temporary variables from a template
- Returns:
No return value
- Return type:
None
Example
To delete all the temporary variables from template t:
t.DeleteTemporaryVariables()
- Template.EditVariables(title=Oasys.gRPC.defaultArg, message=Oasys.gRPC.defaultArg, update=Oasys.gRPC.defaultArg, variables=Oasys.gRPC.defaultArg, columns=Oasys.gRPC.defaultArg, alphabetical=Oasys.gRPC.defaultArg)¶
Start a dialog to edit the template variables
- Parameters:
title (string) – Optional. Title for dialog. If omitted, None or an empty string is given then the default title will be used
message (string) – Optional. Message to show in dialog. If omitted, None or an empty string is given then the default message will be used
update (boolean) – Optional. Whether the variables in the template will be updated with the new values if OK is pressed. Setting this to be false allows you to check variable values before updating them from a script. If omitted the default is true
variables (list) – Optional. A list of variables to show in the dialog. If omitted, None or an empty list, all variables will be shown
columns (constant) – Optional. Columns to show in the dialog (as well as the variable value column). Can be a bitwise OR of
Variable.NAME
,Variable.TYPE
,Variable.DESCRIPTION
,Variable.FORMAT
,Variable.PRECISION
andVariable.TEMPORARY
. If omitted columns will be shown for name and descriptionalphabetical (boolean) – Optional. Whether to sort variables in the table by alphabetical order. If false, variables are listed in the order they are passed in the optional variables argument. If no variables are passed to the function, all template variables will be shown in alphabetical order. If omitted, the default value is true
- Returns:
Dict containing the variable names and values or None if cancel was pressed
- Return type:
dict
Example
To edit all of the variables in template:
variables = template.EditVariables()To edit variables TEST and EXAMPLE in template giving a title and a message, returning the edited values but not updating them in the template:
variables = template.EditVariables("Edit variables", "Type in the values", False, ["TEST", "EXAMPLE")
- Template.ExpandVariablesInString(string)¶
Replaces any variables in a string with their current values
- Parameters:
string (string) – The string you want to expand variables in
- Returns:
String (string) with variables expanded. If a variable in a string does not exist it is replaced by a blank
- Return type:
str
Example
If the variable FRED in template contains the value “test”, then the following
value = template.ExpandVariablesInString("This is a %FRED%")will return “This is a test” in variable value
- Template.Generate()¶
Generate a template
- Returns:
no return value
- Return type:
None
Example
To generate template data:
data.Generate()
- Template.GetAllPages()¶
Gets all of the pages from a template
- Returns:
List of Page objects
- Return type:
list
Example
To get all of the pages from template t:
pages = t.GetAllPages()
- Template.GetMaster()¶
Get the master page from a template
- Returns:
Page object
- Return type:
dict
Example
To get the master page of template t:
m = t.GetMaster()
- Template.GetPage(index)¶
Get a page from a template
- Parameters:
index (integer) – The index of the page that you want to get. Note that indices start at 0
- Returns:
Page object
- Return type:
dict
Example
To get the first page of template t:
p = t.GetPage(0)
- Template.GetVariableDescription(name)¶
Get the description for a variable
- Parameters:
name (string) – Variable name you want to get description for
- Returns:
Variable description (string) or None if variable does not exist
- Return type:
str
Example
To get description for variable FRED in template:
description = template.GetVariableDescription("FRED")
- Template.GetVariableValue(name)¶
Get the value for a variable
- Parameters:
name (string) – Variable name you want to get value for
- Returns:
Variable value (string) or None if variable does not exist
- Return type:
str
Example
To get value for variable FRED in template:
value = template.GetVariableValue("FRED")
- Template.Html(filename)¶
Save a template as HTML
- Parameters:
filename (string) – Filename you want to save
- Returns:
no return value
- Return type:
None
Example
To save template data as file /data/test/template.html:
data.Html("/data/test/template.html")
- Template.Pdf(filename)¶
Save a template as Adobe Acrobat PDF
- Parameters:
filename (string) – Filename you want to save
- Returns:
no return value
- Return type:
None
Example
To save template data as file /data/test/template.pdf:
data.Pdf("/data/test/template.pdf")
- Template.Pptx(filename)¶
Save a template as PowerPoint
- Parameters:
filename (string) – Filename you want to save
- Returns:
no return value
- Return type:
None
Example
To save template data as file /data/test/template.pptx:
data.Pptx("/data/test/template.pptx")
- Template.Print(printer)¶
Print template on a printer
- Parameters:
printer (string) – Printer you want to print to
- Returns:
no return value
- Return type:
None
Example
To print template data on printer myprinter:
data.Print("myprinter")
- Template.Save()¶
Save a template
- Returns:
no return value
- Return type:
None
Example
To save template data:
data.Save()
- Template.SaveAs(filename)¶
Save a template/report with a new name
- Parameters:
filename (string) – Filename you want to save. Note if you use the .orr extension the template will be saved as a report if generated
- Returns:
no return value
- Return type:
None
Example
To save template data as file /data/test/template.opt:
data.SaveAs("/data/test/template.opt")
- Template.Update()¶
Update/redraw a template
- Returns:
no return value
- Return type:
None
Example
To update template data:
data.Update()