Show element thickness

This script will show the thickness of shell elements using the element thickness variable. It automatically identifies the correct thickness variable for these readers: Ansys Results, LS-DYNA3D, LS-DYNA_Beta, MSC/Dytran, Nastran OP2 (beta.

Example images using ‘blade out’ example model. Image on left is original model. Image on right is after running the script.

element_thickness_side_by_side

The script works by creating one or two elevated surfaces for each selected surface part and hides the original parts.

Running the script will show a GUI with several options. Checking “Match part colors” will give the elevated surface parts the same color as their parent parts so the model looks the same other than the thickness.

element_thickness_screenshot

Download the script: element_thickness_gui

Smoke rendering for FDS

From the official site for FDS:

Fire Dynamics Simulator (FDS) is a large-eddy simulation (LES) code for low-speed flows, with an emphasis on smoke and heat transport from fires.

Smokeview (SMV) is a visualization program used to display the output of FDS and CFASTsimulations.

FDS+Evac is the evacuation simulation module for FDS.

These tools are open source and freely available.

FDS smoke 2

One use of FDS is simulation of visibility through smoke. The most realistic way to visualize smoke is volume rendering, which the default post processor Smokeview can do.

EnSight volume rendering color and transparency are customizable by the user, so they cannot be relied upon to accurately represent the visibility through smoke. The attached document and python script present a method which sets the volume rendering opacity in EnSight to accurately represent visibility. With minor modification the script also applies to any data that has a light extinction coefficient or optical density variable.

Analysis and python script.

A session file containing this dataset can be downloaded here.

Prepare cube tool for a skybox

Here is a very short script that prepares the cube tool to make a skybox. Just change the numbers in the first 2 lines and go. Then create the skybox manually.

skbox_size=1000
skbox_center=[0,0,0]
ensight.tools.box(“ON”)
ensight.view_transf.function(“box”)
ensight.view_transf.box_length(skbox_size,skbox_size,skbox_size)
ensight.view_transf.box_origin(-skbox_size/2+skbox_center[0],-skbox_size/2+skbox_center[1],-skbox_size/2+skbox_center[2])
ensight.view.highlight_parts(“OFF”)
ensight.tools.box(“OFF”)

Moving car animation

This script assists in creating an animation with frame mode. It makes the car appear to move and wheel spin at a rate that matches the car’s speed. It can do constant speed as well as constant acceleration and deceleration.

First create 3 frames (ground and background, front wheels, rear wheels) and assign them to the parts. Then adjust the settings at the beginning of the script. The car will stay stationary while the ground moves in the opposite direction to give the appearance of motion.

Download: drive_car.py

Texture mapping tool

This code enables a very simple and handy way of texture mapping. The code can handle pre-selected (multiple) parts or the user can select a single part within the script GUI. Additionally the mapping direction and the texture image must be chosen. Now click “Create” and the code will automatically grab the dimension of all selected parts and map the texture over the whole part surface. The GUI remains open so the user can rotate the plane tool for adjusting the texture.

http://pythonexchange.com/?attachment_id=816

Continue reading

Creating Custom Color Palette from Image

Suppose you have an image that was created in another package, and you would like to replicate the color palette used in the image within EnSight? Well, EnSight can easily accept custom Color Palettes (see UserManual). The only “tough” part is getting from original image file the RGB values used and into a form of the EnSight Color Palette (.cpal) file. Well, guess what, Python (and more specifically EnVe) can be used to grab out the color legend information, and create your own color palette file (.cpal) for EnSight.

So, how you go about doing this:

1. Start with an image created in another package, which has a color legend. Crop the image to just the color legend palette. You now have an image file which has (in this example) a vertical specification of the color palette.

2. Use the attached python routine below on this file image file. This python routine uses EnVe to query the image file for the RGB values of the pixels in the image, and grab those values off, and write out an EnSight Color Palette file (.cpal) with the appropriate information in it. (If your image has a horizontal legend, then you can switch the x,y values around to perform the same operation).

3. You can thus create a new EnSight Color Palette File (.cpal) from the original image created in another package. EnSight has a limit of 21 bands, but handles 16 colors per band for smooth palette range.

 

As always, please contact us here at CEI should you have any questions, comments, having trouble, or would like routines this customized to your needs. We are here to help.

Click here for Color Palette Create Tool

 

Vector length legend for vector arrows

This script requires some effort from the user and if used incorrectly it could lead to wrong or misleading information.

One of the EnSight created part types is a “Vector Arrow” part. The length of these arrows can be in proportional to the magnitude of the vector used to create them (the arrows can also be set to have uniform length). So the length of the arrows has definite meaning, but there is no ‘legend’ like the color palette legend which indicates what the length of a vector arrow means.

This script can create such a legend semi-automatically, but the legend is only accurate in certain situations. Since the arrows and the legend are in a 3D space, the direction the arrows are viewed from will affect how large the arrows appear. So I recommend using this legend only in certain situations such as:

  1. When all the arrows lay in a 2D plane, and they are viewed orthogonally with perspective view turned off (orthographic view mode)
  2. When the viewer can rotate the view, and therefore gauge the 3D scene and have an intuitive feeling about the distortion in size due to the viewer’s perspective

Example: The arrow length shows velocity while color indicates temperature.

The script performs a few simple steps:

  1. Create a single node using a point part
  2. Create a vector variable of unit magnitude on the node using MakeScalNode and MakeVect
  3. Create a vector arrow part on this node using this vector variable

The script will prompt you for the location and direction of the arrow. If desired, the location of the arrow can be changed by editing the point part. After the script runs the user should do two things:

  1. Adjust the arrow length by changing the scale factor of the Vector Arrow Legend part
  2. Create a text annotation indicating the meaning of the length of the reference arrow

One must be careful when scaling the legend arrow so that it represents the correct value. One could follow these steps:

  1. Adjust the scale factor of your vector arrow part(s) (not the legend part) to get the desired vector lengths. Call the scale factor “A”.
  2. Choose a vector value that you want the legend to represent, call this value “B”
  3. A * B = C, C is the scale factor you should use for the Vector Arrow Legend part (since the original vector magnitude is one). Now the legend arrow should be the same length in 3D space as an arrow that has vector value B.
  4. The text annotation should use the value B

Download the script. vector_legend.py

If you like the idea of a vector arrow length legend and would like to see it added as a standard feature of EnSight you can vote for it and other features at ideas.ceisoftware.com. Link to the arrow legend request

Create a plane part

This is a simple tool but it may come in handy. Sometimes you just want to create some simple geometry, and probably the most common geometry to make is a plane. EnSight has the capability to create points and mesh them in various ways. This capability is called point parts, but it is cumbersome to specify each point manually.

This tool uses the location of the plane tool to create a point part and mesh the points to create a surface. The resulting part is a plane at the exact size and location of the plane tool. The new part can be colored and textured as desired, but it will have no variable information.

Example: This tool used to create a road for the guard rail demo model.

Just plug and chug with this tool. Don’t try to modify a created plane, just delete it and make a new one. Use the tool repeatedly to create multiple planes.

Download tool and icon. (updated 2012-09-28)

create_plane_part.zip

Show a multi-colored overlay mesh

This simple script will create the effect of a “hidden line’ display but with more coloring options than are normally available. The script does not do anything that cannot be done through the EnSight GUI but it does make it easier. Also, only fairly advanced users of EnSight would be aware that it is even possible. To use this script just set the view and part colors how you want them, then run the script as a UDT.

colored_mesh.zip (updated 2014-2-21)

Basically the script does these steps:
Part selection: Applies to selected and visible parts only. If no parts are selected it is applied to all visible parts. Only 2D parts and 3D parts in border representation are affected.
1. Creates copies of the original parts and colors these parts gray.
2. Creates a black ‘outline’ part by taking an extract of 2D parts (in border rep) and 3D parts (in feature angle rep). (Skips this step by default. Set “CREATE_EDGES = True” on line 24.)
3. Turns element shading of original parts off and sets line thickness to 2.

The effect is that the ‘hidden line’ display is show with the colors of the original parts, on top of gray shaded parts.

The script attempts to have a minimal effect on the original parts. To return to the original view just do steps:
1. Delete or hide the created copy and extract parts
2. Turn on part shading of the original parts

Side by Side Animations

As an engineer working with multiple solutions, or comparing multiple variables, it is quite useful to be able to compare images side by side, but also animations side by side. Image comparison side by side is quite easily done with Word, or Powerpoint, or even image viewers. However, the comparison of multiple animations in a side by side layout is not quite so straight forward. Sure, there are probably some fancy, and/or expensive options out there for video editing, but there is a simpler solution —- EnVe from EnSight.

Given two animations of equal length (number of frames), EnVe’s multiple tiled movie format (.mtm) can be utilized to place two animations side by side, and a new single animation created.

Here are two example animations:

Case 1 AVI

Case 2 AVI

These two animations are each 826 pixels in X, and 574 pixels in Y, and each are 30 frames. In this example of side-by-side, both animations should be the same height (but could vary in width). You can also place the animations one on top of the other, in which case you’d want to have the animations the same width, but could vary each heights.

A Simple “Multiple Tiled Movie Format” file (.mtm) contains information about how to arrange these two animations together. Here is what that file looks like:

MTM 1.0
#
# This is a Multi-Tile Movie file.
#

nummovies 2

fullresolution 1652 574

movie
   imageoffset 0 0
   format AVI
   file Case1.avi

movie
   imageoffset 826 0
   format AVI
   file Case2.avi

You can see above that we set the total number of movies, and the total dimensions of the two movies together (1652 x 574). For each movie, you can therefore set the offset (from the lower left corner). Movie #1 will have a zero offset in X and Y, while Movie #2 will be offset by 826 pixels in X.

You can read this .mtm file into EnVideo, and view a live playing of two animation files, or you can read the .mtm file into EnVe, and simply save out a new single animation file which will have both animations playing side by side. This works great to control the comparison of different models, results, or different variables from separate single animations. Given the flexibility of the .mtm file, you can tile many animations together to make a multiple animation comparison easily and without cost.

Please see below a link which has the animation files, mtm file, and the combined movie example.

Multiple Animation Example

Please see the attached PDF file for similar other operations that can be performed using EnVe… Using EnVe to Create a Single Movie from Existing Movies that Play Simultaneously