Tools#

Some examples require external input files. Before you start, please follow the link in the Example Scripts section to download the zip file with model and result files.

Example 01 - Log HWC in Python#

Using evalHWC() wrapper to log HWC in Python syntax#
 1import os
 2import hw
 3
 4scriptDir = os.path.abspath(os.path.dirname(__file__))
 5modelFile = os.path.join(scriptDir, "aerobox", "aerobox.fem")
 6resultFile = os.path.join(scriptDir, "aerobox", "aerobox-LC1-2.op2")
 7
 8hw.evalHWC("delete session")
 9hw.evalHWC("hwd page current activewindow=1")
10hw.evalHWC("hwd window type=HyperView")
11hw.evalHWC("delete session")
12hw.evalHWC("hwd window type = HyperView")
13hw.evalHWC("open animation  modelandresult " + modelFile + " " + resultFile)
14hw.evalHWC("view fit allframes = true")
15hw.evalHWC("hwd page current layout = 9")
16hw.evalHWC("hwd window copy")
17hw.evalHWC("hwd window paste window = 2")
18hw.evalHWC("hwd page current activewindow = 3")
19hw.evalHWC("hwd window paste")
20hw.evalHWC("hwd page current activewindow = 4")
21hw.evalHWC("hwd window paste")
22hw.evalHWC("hwd page copy")
23hw.evalHWC("hwd page add title = Untitled")
24hw.evalHWC("hwd page paste")
25hw.evalHWC("hwd page overlay page = 2")
../../_images/image_HV_Python_evalHWC.PNG

Figure 1. Recording of copying/overlaying windows and pages

Example 02 - H3D in HTML Export#

Export H3D file into HTML file with customized settings#
 1import hw
 2import hw.hv as hv
 3import os
 4import webbrowser
 5
 6ALTAIR_HOME = os.path.abspath(os.environ['ALTAIR_HOME'])
 7modelFile   = os.path.join(ALTAIR_HOME,'demos','mv_hv_hg','animation','dyna','bumper','bumper_deck.key')
 8resultFile  = os.path.join(ALTAIR_HOME,'demos','mv_hv_hg','animation','dyna','bumper','d3plot')
 9htmlFile    = os.path.normpath(os.path.join(os.getcwd(),'H3D_to_HTML.html'))
10
11ses = hw.Session()
12ses.new()
13win=ses.get(hw.Window)
14# Set Window to Animation
15win.type = 'animation'
16# Add Model
17win.addModelAndResult(modelFile, result=resultFile)
18# Set scalar, vector and tensor results
19res = ses.get(hv.Result)
20resScalar = hv.ResultDefinitionScalar(dataType='Stress',
21                  dataComponent='vonMises',
22                  layer='Max')
23res.plot(resScalar)
24# Set time step
25animTool=hw.AnimationTool()
26animTool.currentFrame=res.getSimulationIds()[-2]
27# Set View
28hw.evalHWC('view orientation back')
29
30print('Run ExportModelH3DinHTML() ...')
31expModH3DtoHTML=hv.ExportModelH3DinHTML()
32expModH3DtoHTML.file=htmlFile
33expModH3DtoHTML.page=1
34expModH3DtoHTML.winodw=1
35expModH3DtoHTML.compressOutput=True
36expModH3DtoHTML.compressionLoss=0.01
37expModH3DtoHTML.animation=True
38expModH3DtoHTML.includeSets=True
39expModH3DtoHTML.includeMaskedElements=True
40expModH3DtoHTML.results=True
41expModH3DtoHTML.viewAttributes=True
42expModH3DtoHTML.export()
43print('Export to "{}" successfully finished!'.format(expModH3DtoHTML.file))
44
45webbrowser.open_new_tab(expModH3DtoHTML.file)
../../_images/image_HV_H3D_HTML_3D_Export.PNG

Figure 2. Web-Browser View on H3D in HTML 3D Export