Methods#

fitView#

fitView(objects=None, padded=True)#

Ensures all visible objects can be seen in the view.

See hwx.inspire.gui.fitView

Example

Ensure that all visible objects can be seen in the view.#
from hwx import inspire
from hwx.common import math

model = inspire.newModel()
block = model.createSolidBlock(position=math.Matrix44(origin=(-2, 0, 0)))
cyl = model.createSolidCylinder(radius=.5, position=math.Matrix44(zv=(1, 1, 0)))
sphere = model.createSolidSphere(radius=.5, position=math.Matrix44(origin=(2, 0, 0)))
inspire.fitView()

orientView#

orientView(direction='top', up=None)#
Rotates your model to a standard view or one specified by a direction

and up vector.

See hwx.inspire.gui.orientView

Example

Set a view direction which can be one of: front, back, left, right, top, bottom, iso. Direction can also be set as a vector specifying direction pointing into the screen. In that case the parameter up is optional and specifies the vector that points up on the screen.#
from hwx import inspire
from hwx.common import math

model = inspire.newModel()
block = model.createSolidBlock(position=math.Matrix44(origin=(-2, 0, 0)))
cyl = model.createSolidCylinder(radius=.5, position=math.Matrix44(zv=(1, 1, 0)))
sphere = model.createSolidSphere(radius=.5, position=math.Matrix44(origin=(2, 0, 0)))
inspire.orientView(direction="left")
# inspire.orientView(direction=[1,1,1], up=[0,1,0])

print("Try changing the direction parameter and see the view changes in the inspire window")

isolate#

isolate(objects)#

Isolates objects in the modeling window.

Isolating an object zooms in and hides all other objects.

Parameters:

objects (list[Named]) –

Example

Hide all but the passed objects and fit the view on them.#
from hwx import inspire
from hwx.common import math

model = inspire.newModel()
block = model.createSolidBlock(position=math.Matrix44(origin=(-2, 0, 0)))
cyl = model.createSolidCylinder(radius=.5, position=math.Matrix44(zv=(1, 1, 0)))
sphere = model.createSolidSphere(radius=.5, position=math.Matrix44(origin=(2, 0, 0)))
inspire.isolate([sphere, block])

print("The inspire window shows only the objects passed to the function isolate")

redrawView#

redrawView(processEvents=False)#

Forces a redraw of the active graphics window. Useful when executing commands from the Console and the graphics are cached or updating the view for animation.

Parameters:

processEvents (bool) – True, makes gui responsive to the user.

Example

Force a redraw of the active graphics window. Useful when executing commands from the Console and the graphics are cached, or updating the view for animation. Calling this at each animation frame with processEvents=True make the rest of the GUI live to the user.#
from hwx import inspire
M44 = inspire.math.Matrix44
model = inspire.newModel()
block = model.createSolidBlock()
inspire.fitView()
for deg in range(360):
block.animationPosition = M44().rotz(deg)
inspire.redrawView()
block.animationPosition = None

showMessage#

showMessage(msg)#

Display a message in the status bar at the bottom left of the main window.

The message remains until clearMessage() or another message is shown.

Parameters:

msg (str) – Message to be displayed in the status bar.

Example

Show the message in the status bar#
from hwx import inspire
inspire.showMessage("This is a demo message")

clearMessage#

clearMessage()#

Removes a message from the status bar.

Example

Clear message from the status bar.#
from hwx import inspire
inspire.clearMessage()

saveSnapShot#

saveSnapShot(filename, background=None, width=1000, height=750, fitToImage=False, showAsUnselected=True, excludeInvisibleObjects=False, excludeOverlays=True, excludeExternalFeatures=True, excludeOtherGraphicTools=True, excludeClipPlanes=False, orientation=None)#

Saves what is currently in the graphics window under the given filename.

Parameters:
  • filename (str) – The complete file name to write the image to. its extension implicitly defines the graphic file format Allowed formats are .jpg, .png.

  • background (str | tuple[float, float, float]) – The desired background color of the snapshot. If not provided, the current gradient background of the active view will be used.

  • width (int) – The desired width of the image.

  • height (int) – The desired height of the image.

  • fitToImage (bool) – If true, fits the objects to be drawn into the image.

  • showAsUnselected (bool) – If true, save the object in the image in its default unselected visualization.

  • excludeInvisibleObjects (bool) – If true, save in the image only the visible parts of the object.

  • excludeOverlays (bool) – If true, exclude from the image any overlay.

  • excludeExternalFeatures (bool) – If true, exclude from the image any non-edge and non-vertex feature of the object

  • excludeOtherGraphicTools (bool) – If true, exclude all other graphics.

  • excludeClipPlanes (bool) – If true, disable all the clip planes applied to the objects, in order to show them entirely.

  • orientation (str) – By default, save the image with current orientation. Valid choices are: - “front” - “back” - “left” - “right” - “top” - “bottom” - “iso”

Example

Saves what is currently in the graphic window to a file.#
import os
from hwx.inspire.gui.Graphics import saveSnapShot
from hwx import inspire

model = inspire.newModel()
part = model.createSolidBlock()
inspire.orientView(direction="isometric")
cwd = os.getcwd()
fname = "SnapShot.png"

#save the snapshot to a file
saveSnapShot(fname)
print("{} is saved at {} successfully.".format(fname,cwd))

saveCurrentResultSnapshot#

saveCurrentResultSnapshot(filename, bgColor=None, width=1000, height=750, fitToImage=False)#

Saves the results graphic window and analysis explorer dialog to a file.

Keep the graphics window as big as possible to get a clear snapshot.

Parameters:
  • filename (str) – The complete file name to write the image to.

  • bgColor (str | tuple[float, float, float]) – The desired background color.

  • width (int) – The desired width of the image.

  • height (int) – The desired height of the image.

  • fitToImage (bool) – If true, fits the objects to be drawn into the image.

Raises:
  • RuntimeError – In case you call the method in batch mode.

  • RuntimeError – In case the Analysis explorer isn’t displayed in the graphics window.

Example

Saves the results graphic window and analysis explorer dialog to a file. Keep the graphics window as big as possible to get a clear snapshot.#
import os
from hwx import inspire
model = inspire.newModel()

# open a tutorial file with results
inspire.openTutorialFile('Structures/1_0_swingarm_IR_FEA_RUN.stmod')
inspire.orientView(direction="isometric")
analysis = model.getChildren(type = inspire.OptiStructAnalysis)[0]

#import the analysis results into graphics
analysis.importResults()
inspire.redrawView(processEvents=True)
cwd = os.getcwd()
fname = "SnapShot.png"

#save the snapshot to a file
inspire.saveCurrentResultSnapshot(fname,height=600)
print("{} is saved at {} successfully.".format(fname,cwd))