hw Module#

AnimationTool class#

class AnimationTool(page=None, **kwargs)#

Bases: object

Class representing the Animation Tool. Provides user with tools to control the animation and its parameters.

Parameters:
  • page (Union[Page, int, str]) – Page the Animation Tool will be linked to. Default is active page.

  • kwargs (dict) – Attributes of the Animation Tool object.

isAnimating()#

Method to check if page is animating.

Returns:

Returns True if page is animating.

Return type:

bool

next()#

Method to set the next frame of the animation.

previous()#

Method to set the previous frame of the animation.

setAttributes(**kwargs)#

Method to set the animation tool attributes.

Parameters:

kwargs (dict) – Attributes

start(num_cycles=0)#

Method to start the animation.

stop()#

Method to stop the animation.

property currentFrame#

Attribute to set or get the current frame of the animation.

Getter:

Gets the current frame of the animation.

Setter:

Sets the current frame of the animation.

Type:

Union[int, str]

property currentTime#

Attribute to set or get the current time of the animation.

Getter:

Gets the current time of the animation.

Setter:

Sets the current time of the animation.

Type:

Union[float, str]

property endFrame#

Attribute to set or get the end frame of the animation.

Getter:

Gets the end frame of the animation.

Setter:

Sets the end frame of the animation.

Type:

Union[int, str]

property endTime#

Attribute to set or get the endTime of the animation.

Getter:

Gets the end time of the animation.

Setter:

Sets the end time of the animation.

Type:

Union[float, str]

property numberOfFrames#

Attribute to get the number of frames.

Getter:

Gets the number of frames.

Type:

int

property numberOfSteps#

Attribute to get the number of steps.

Getter:

Gets the number of steps.

Type:

int

property page#

Attribute to get the page.

Getter:

Gets the page.

Type:

Page

property startFrame#

Attribute to set or get the start frame of the animation.

Getter:

Gets the start frame of the animation.

Setter:

Sets the start frame of the animation.

Type:

Union[int, str]

property startTime#

Attribute to set or get the start time of the animation.

Getter:

Gets the start time of the animation.

Setter:

Sets the start time of the animation.

Type:

Union[float, str]

CaptureImageTool class#

class CaptureImageTool(*args, **kwargs)#

Bases: object

Class representing the Capture Image Tool. Provides user with tools to define and capture screenshots.

Parameters:

kwargs (dict) – Attributes of the Capture Image Tool object.

capture()#

Method to capture the image and save it as a file. If the file name is not specified, the name will be set to untitled followed by an incremental value (e.g. untitled1.jpg).

setAttributes(**kwargs)#

Method to set the CaptureImageTool attributes.

Parameters:

kwargs (dict) – Attributes

property area#

Attribute to set or get area to capture in image. Default is window. Available options are window or page.

Getter:

Gets the capture image area.

Setter:

Sets the capture image area.

Type:

str

property compression#

Attribute to set or get compression for capture image. Default is 100.

Getter:

Gets the capture image compression.

Setter:

Sets the capture image compression.

Type:

int

property dimension#

Attribute to set or get capture image dimension. Default is pixels. Available options are percent or pixels.

Getter:

Gets the capture image dimension.

Setter:

Sets the capture image dimension.

Type:

str

property file#

Attribute to set or get the capture image file name.

Getter:

Gets the capture image file name.

Setter:

Sets the capture image file name.

Type:

str

property height#

Attribute to set or get the height of the capture image window. Default value is 768 in batch mode, otherwise the page height.

Getter:

Gets the capture image window height.

Setter:

Sets the capture image window height.

Type:

float

property type#

Attribute to set or get the capture image type. Default is clipboard. Available options are jpg, jpeg, png, tif, bmp or clipboard.

Getter:

Gets the capture image type.

Setter:

Sets the capture image type.

Type:

str

property width#

Attribute to set or get the width of the capture image window. Default is 1024 in batch mode, otherwise the page width.

Getter:

Gets the capture image window width.

Setter:

Sets the capture image window width.

Type:

float

Color class#

class Color(*, rgb=(0, 0, 0), hex='#000000', bgr=(0, 0, 0))#

Bases: object

Class representing colors in various formats (RGB, BGR, and Hex). A Color object can be referenced to define an entity color.

property bgr: tuple#

Tuple representing the color in BGR format.

property hex: str#

String representing the color in hexadecimal format.

property postIndex: int#

Sets the color using a HyperView/HyperGraph client index. Valid values are 1-64.

property preIndex: int#

Sets the color using a HyperMesh client index. Valid values are 0-63.

property rgb: tuple#

Tuple representing the color in RGB format.

Font class#

class Font(*args, **kwargs)#

Bases: object

Class representing a font specified by the family, size, and style configuration.

Parameters:

kwargs (dict) – The attributes of the Font.

setAttributes(**kwargs)#

Set the attributes of the Font object.

Parameters:

kwargs (dict) – The attributes of the Font.

property family: str#

Set the font family attribute.

property size: int#

Set the font size attribute.

property style: str#

Set the font style attribute.

HyperGraphWindow class#

class HyperGraphWindow#

Bases: Window

Class representing a HyperGraph Window. Gets a HyperGraph Window for the given page.

delete(entity, objOrId)#

Method to delete an entity.

Parameters:
  • entity (class) – Entity class.

  • objOrId (Union[Entity, int, list, str]) – Entity object, entity ID, list of entity objects, list of entity IDs, or all.

fit(x=True, y=True)#

Method to adjust the view to fit the curves in the plot window.

Parameters:
  • x (bool) – If True, the curves will be fitted along x axis.

  • y (bool) – If True, the curves will be fitted along y axis.

recalculate()#

Method to recalculate the curves in the window.

update()#

Method to recalculate the curves, fit the curves along both x and y axis, and redraw the window.

property axisGradient#

Attribute that activates the axis gradient for the window.

Getter:

Gets the flag for the axis gradient for the window.

Setter:

Sets the flag for the axis gradient for the window.

Type:

bool

property backgroundColor#

Attribute that sets the background color for the window.

Getter:

Gets the background color for the window.

Setter:

Sets the background color for the window.

Type:

Union[int, str, tuple, Color]

property cursorAlwaysVisible#

Attribute that determines whether the animation cursor is always shown in the window.

Getter:

Gets the flag whether the animation cursor is always shown in the window.

Setter:

Sets the whether the animation cursor is always shown in the window.

Type:

bool

property gridLineColor#

Attribute that sets the grid line color for the window.

Getter:

Gets the grid line color for the window.

Setter:

Sets the grid line color for the window.

Type:

Union[int, str, tuple, Color]

property gridLineTransparency#

Attribute that sets the grid line transparency for the window. The value varies between 0-1 to display the gridline’s transparency.

Getter:

Gets the grid line transparency for the window.

Setter:

Sets the grid line transparency for the window.

Type:

float

property lock#

Attribute to set the lock options for the axis in the window. Options available: [‘never’, ‘atimport’, ‘always’] ‘never’ : The selected axis is automatically scaled to fit new curves that are added to the axis. ‘atimport’ : The selected axis remains scaled to fit the curve(s) currently assigned to it and it is not scaled to fit new curves. ‘always’ : The axes are not fit with any of the operations and will always be locked.

Getter:

Gets the lock options for the axis in the window.

Setter:

Sets the lock options for the axis in the window.

Type:

str

property publishFormat#

Attribute to set the publish format for the window. The publish formats available are [‘jpg’,’png’,’bmp’,’gif’,’tif’,’emf’]

Getter:

Gets the publish format for the window.

Setter:

Sets the publish format for the window.

Type:

str

property publishWindow#

Attribute that determines whether to publish the current window contents.

Getter:

Gets the flag to publish the window content.

Setter:

Sets the flag to publish the window content.

Type:

bool

property type#

Attribute to set or get the type of window client.

Getter:

Gets client of the window.

Setter:

Sets client of the window.

Type:

str

property zeroLineColor#

Attribute that sets the zero line color for the window.

Getter:

Gets the zero line color for the window.

Setter:

Sets the zero line color for the window.

Type:

Union[int, str, tuple, Color]

HyperViewWindow class#

class HyperViewWindow#

Bases: Window

addModelAndResult(model=None, result=None, overlay=False, template='none')#

Method to load model and result.

Parameters:
  • model (str) – Model file name.

  • result (str) – Result file name.

  • overlay (bool) – If True, overlays the model.

  • template (str) – Template used to load model and result.

addResult(resFiles, replace=False)#

Method to add results.

Parameters:
  • resFiles (Union[str, list]) – Result file name.

  • replace (bool) – If True, replaces the currently loaded result file.

delete(entity, objOrId)#

Method to delete an entity.

Parameters:
  • entity (class) – Entity class.

  • objOrId (Union[Entity, int, list, str]) – Entity object, entity ID, list of entity objects, list of entity IDs, or all.

fit(mode: str = 'model')#

Method to adjust the view to fit the objects in the modeling window.

Parameters:

mode (str) – Mode of the fit operation. Valid values are model (default), selected, and allframes.

getActiveModel()#

Method to get the active model object.

Returns:

Model object.

Return type:

Model

getModel(id: int)#

Method to get the model object.

Parameters:

id (int) – The ID of the model.

Returns:

Model object.

Return type:

Model

getModels() list#

Method to get the model object list.

Returns:

Model object list.

Return type:

list

getResultDefinitionList(type: str)#

Method to get the ResultDefinition object list.

Parameters:

type (int) – Type of ResultDefinition (scalar, vector, or tensor)

Returns:

Model object.

Return type:

Model

setActiveModel(id: int)#

Method to set the active model and returns model object.

Parameters:

id (int) – The ID of the model.

Returns:

Model object.

Return type:

Model

update()#

Method to fit the model and draw the window.

property sectionFeatureLines#

Attribute to set or get feature lines of the Section cut.

Getter:

Gets the feature lines of the SectionCut.

Setter:

Sets the feature lines of the SectionCut.

Type:

bool

property sectionTransparency#

Attribute to set or get transparency of the Section cut.

Getter:

Gets the transparency of the SectionCut.

Setter:

Sets the transparency of the SectionCut.

Type:

bool

Page class#

class Page(layout=0, title='Untitled', _obj=None, _id=0)#

Bases: object

Class representing a page of the application. The constructor raises an exception if not pointed to a valid page.

Parameters:
  • layout (int) – The page layout.

  • title (str) – The page title.

draw(updateInterface: bool = False)#

Method to draw the page.

Parameters:

updateInterface (bool) – If True, the graphics are updated.

getAverageAnimationFramerate()#

Method to get the average animation frame rate.

Returns:

Animation frame rate.

Return type:

int

getNumberOfWindows() int#

Method to get the number of windows on a page.

Returns:

Number of windows on a page.

Return type:

int

isAnimating()#

Method to check if page is animating.

Returns:

Returns True if page is animating.

Return type:

bool

setAttributes(**kwargs)#

Method to set the page attributes.

Parameters:

kwargs (dict) – attributes

startAnimation(num_cycles=0)#

Method to start the animation.

Parameters:

num_cycles (int) – Number of animation cycles defining how many times animation will be repeated (default 0).

stopAnimation()#

Method to stop the animation.

property id#

Attribute to get the ID of the page.

Getter:

Gets the ID of the page.

Type:

int

property layout#

Attribute to set or get the window layout of the page. Valid values are 0-19.

Getter:

Gets layout of the page.

Setter:

Sets layout of the page.

Type:

int

property title#

Attribute to set or get the page title.

Getter:

Gets title of the page.

Setter:

Sets title of the page.

Type:

str

property titleAsDisplayed#

Attribute to get the displayed title (after evaluation of any embedded expressions).

Getter:

Gets the displayed page title.

Type:

str

Session class#

class Session#

Bases: object

A singleton class representing the Session. All session level attributes and methods are defined in this class.

close()#

Method to close the session.

delete(entity, objOrid)#

Method to delete an entity.

Parameters:
  • entity (Page) – Entity to be deleted. Currently only supported for Page class.

  • objOrid (Union[int, str, Page, list]) – ID, title, Page object or list of IDs, titles or Page objects.

classmethod get(tag, id: Any | None = None, label: str | None = None, title: str | None = None, page: int | Page | None = None, window: int | Window | None = None, model=None, curve: Any | None = None, reference: str | None = None, labelAsDisplayed: str | None = None, name: str | None = None, curveLabelAsDisplayed: str | None = None, curveLabel: str | None = None, operation: str | None = None)#

Method to get an entity object of class Page, Window, Model, Result, ResultDefinitionScalar, ResultDefinitionVector, ResultDefinitionTensor, ResultDefinitionIso, ResultDisplayIso, LegendScalar, LegendTensor, LegendVector, Note, CurveXY, DatumHorizontal, DatumVertical, AxisHorizontal, AxisVertical, Header, Footer, MathXY,SectionCutPlanar,SectionCutSpherical.

Parameters:
  • tag (class) – The class of the entity to get.

  • id (int) – id of the entity.

  • label (str) – label of the entity.

  • title (str) – title of the entity

  • page (Union[Page, int]) – Page of the entity specified as either a Page object or ID. Default is active page.

  • window (Union[Window, int]) – Window of the entity specified as either a Window object or ID. Default is active window.

  • model (Union[Model, int]) – Model specified either as a Model object or ID.

getMultiCoreMode()#

Method to get the MultiCore mode. Applicable for HyperView client.

Returns:

Returns True if MultiCore profile is loaded.

Return type:

bool

getPages() list#

Method to get the pages.

Returns:

List of Page class objects.

Return type:

list

getWindows(page: Any | None = None) list#

Method to get the windows in specified page.

Parameters:

page (Union[Page, int, str]) – Page for the windows. Default is active page.

Returns:

List of windows in given page.

Return type:

list

load(filename, append=True)#

Method to load the session.

Parameters:
  • filename (str) – Session file name.

  • append (bool) – If True, appends the given file to the existing session. Default is True.

new()#

Method to create a new session.

save(filename=None)#

Method to save the session.

Parameters:

filename (str) – Session file name. If filename is not specified, it will save the session as Untitled.mvw.

setActive(tag, id: Any | None = None, title: str | None = None, page: int | Page | None = None, window: int | Window | None = None, model=None)#

Method to set the active entity like Page, Window, or Model.

Parameters:
  • tag (Page, Window or Model) – Entity to be set as active. Applicable for Page, Window or Model.

  • id (int) – ID of the entity.

  • title (str) – Title of the entity. Applicable for Page and Model.

  • page (Union[Page, int]) – Page of the entity specified as either a Page object or ID. Default is active page.

  • window (Union[Window, int]) – Window of the entity specified as either a Window object or ID. Default is active window.

  • model (Union[Model, int]) – Model specified either as a Model object or ID.

Window class#

class Window(page=None, window=None, id=None)#

Bases: object

Class representing a Window. Get a Window for the given page. The constructor raises an exception if not pointed to a valid window.

Parameters:
  • page (Union[int, Page, str]) – The page of the window.

  • window (Union[int, Window]) – The specific window.

  • id (int) – ID of the window

draw()#

Method to draw the window.

erase()#

Method to erase window content.

isEmpty()#

Method to check if window is empty.

Returns:

Returns True if window is empty.

Return type:

bool

setAttributes(**kwargs)#

Method to set window attributes.

Parameters:
  • kwargs – Attributes

  • type – dict

property graphicsHeight#

Attribute to get the window height.

Getter:

Window height.

Type:

int

property graphicsWidth#

Attribute to get the window width.

Getter:

Window width.

Type:

int

property id#

Attribute to get the window ID.

Getter:

Gets the window ID.

Type:

int

property page#

Attribute to get the Page class object.

Getter:

Gets page object.

Type:

Page class object

property publishFormat#

Attribute to set or get the publish format for the Window. For HV valid values are ‘jpg’,’png’,’bmp’,’gif’,’tif’,’avi’,’h3d’. For HG valid values are ‘jpg’,’png’,’bmp’,’gif’,’tif’,’emf’.

Getter:

Gets the publish format for the Window.

Setter:

Sets the publish format for the Window.

Type:

str

property type#

Attribute to set or get the type of window client.

Getter:

Gets client of the window.

Setter:

Sets client of the window.

Type:

str

evalHWC function#

evalHWC(command_or_file: str)#

Evaluates a HWC based expression. Alternatively, if supplied a path to a HWC command file, it executes the command file.

Parameters:

command_or_file (str) – HWC expression or path to HWC command file.

Example#

Clearing scalar and iso plot using HWC in Python#
import hw

hw.evalHWC('result scalar clear "Stress, vonMises, Max, Analysis System')
hw.evalHWC('result iso clear')

evalTcl function#

evalTcl(command: str)#

Evaluates a Tcl based expression.

Parameters:

command (str) – Tcl expression

Returns:

The return value of the evaluated Tcl expression.

Return type:

str

Example#

Sourcing a Tcl file in Python and assigning the returned value to a variable#
import hw

returned_str = hw.evalTcl('source {C:/Scripts/post_processing_util.tcl')