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.


Continue reading

Quick save a plot as an image

This simple script provides a fast way to save a singular plot as an image, with no other objects from the graphics window visible.

It provides a few options that need to be edited in the file (notably the image save path) and a few other options that are specified in a pop-up window. I think usage is fairly straight forward. If this script is used often, one will probably want to remove the pop-up window and set the options to the desired defaults inside the script. The script should work regardless of whatever else is visible in the graphics window, and should restore the view to it’s original state after running. Multiple viewports are supported, but the script may fail if the maximum allowed 16 viewports exit.

The saved images will be named after the Plot name. In a duplicate filename exists the new name will be modified (existing images will not be overwritten).

Added a toggle in the GUI to allow toggling the background color automatically using EnSight.

Download the script image_plot2.py (updated April 23, 2014)

Gradient textures for coloring with two variables

EnSight has the ability to color a single part by 2 different variables by using a bitmap texture. Each axis of the texture is assigned to one variable. A sample image is included with EnSight (dual_gradient.png in the cube data directory) which has one axis as color and the other axis as transparency. Sometimes the user may want to use different colors for each axis instead of transparency, but this requires having the texture to use.

This script uses EnVe to create a custom image for this purpose, by letting the user define the colors of the 4 corners of a 256×256 square, and interpolating the color values between them. It is a barebones script with little documentation, but is also short and simple to use. In this post is also an archive with a few images created with the script.

Images: gradient_textures.zip

Script: make_image_4_color_square.py

Below is a screenshot of the textures dialog, with the settings changed to the optimal settings for using gradient textures (in most cases).

Texture Mode: Decal or Replace

Repeat Mode: Clamp or Clamp to Texture

Interpolation: Nearest

Compute Texture Coordinates by: Variables

S Variable and T Variable: select 2 scalar variables. Ideally the range of these variables are between 0 and 1. Read the How To manual for more information.

Note that if your variable values var1 + var2 <= 1 (for example mass, volume, or mole fraction) then you will only use the bottom-left triangle half of the square.