Associate file extensions to language in Notepad++

Notepad++ 7.8.6

If your writing code in languages that are based on a common language but their files names have an uncommon extension, for example, the 3D shading languages OSL, and HLSL, which are written in C syntax but have .osl and .hlsl, or .fx as file name extensions,
Notepad++ wont automatically recognize that the code in these files is actually C language and present their syntax properly.

To set Notepad++ to recognize specific file associations with a wanted language:

  1. Goto:
    Settings > Style Configurator:
    Annotation 2020-06-18 132154
  2. In the Style Configurator window:
    Select the wanted language in the language list on the left,
    And in the User ext. field, type a list of file extensions separated by spaces:
    These file extensions will be interpreted as the selected language.
    Annotation 2020-06-18 132359


Setup a GitHub to associate file extension with a  language
Display tabs in Notepad++

Python for 3ds max – Loading an image file and reading pixel values

3ds max 2020

An example of loading and displaying an image file using Python for 3ds max:
* The EXR image file is located in in the same directory with the 3ds max file in this case.
Annotation 2020-05-12 123229
from MaxPlus import BitmapManager
image_file_path = r'BG_park_A.exr'
bmp_storage = MaxPlus.Factory.CreateStorage(17)
bmp_info = bmp_storage.GetBitmapInfo()
bmp = BitmapManager.Load(bmp_info)

Script explanation line by line:
1. Import the BitmapManager class needed to load image files.
2. Set a variable containing the path to the image file
3. Call the MaxPlus.Factory class’s CreateStorage method to initiate a BitmapStorage object.
This is embarrassing IMO..
And it may very well be that I simply didn’t find the correct way it should be done..
I couldn’t find any other way to independently initiate the BitmapInfo object needed for loading the image, other than Initiating a BitmapStorage object and getting referece to its BitmapInfo object. (the BitmapInfo class has no constructor..)
* If you know a better method to do this I’ll be very grateful if you take the time to comment.
that the 17 integer argument we supply sets the storage to be compatible with:
32-bit floating-point color depth format (without an alpha channel).
See list of other color format options in this example here:
* They wrote a class containing convenient named constants of the integer arguments (see example code below).
* In this example of creating the BitmapStorage just as a way to generate a BitmapInfo object the actual format you’l supply doesn’t matter, but you can’t use a format that can’t be written to like 8 for example (see list below)
4. Get a reference to the BitmapInfo object contained in the BitmapStorage object.
5. Setting the name property (full file path) of the BitmapInfo object.
6. Loading the image.
7. Displaying the image in 3ds max‘s image viewer window.

Example code for a BitmapStorage format constants container class:

* This example’s source is in the 3ds max help Python examples:
class BitmapTypes(object):
     BMM_NO_TYPE = 0 # Not allocated yet
     BMM_LINE_ART = 1 # 1-bit monochrome image
     BMM_PALETTED = 2 # 8-bit paletted image. Each pixel value is an index into the color table.
     BMM_GRAY_8 = 3 # 8-bit grayscale bitmap.
     BMM_GRAY_16 = 4 # 16-bit grayscale bitmap.
     BMM_TRUE_16 = 5 # 16-bit true color image.
     BMM_TRUE_32 = 6 # 32-bit color: 8 bits each for Red, Green, Blue, and Alpha.
     BMM_TRUE_64 = 7 # 64-bit color: 16 bits each for Red, Green, Blue, and Alpha.
     BMM_TRUE_24 = 8 # 24-bit color: 8 bits each for Red, Green, and Blue. Cannot be written to.
     BMM_TRUE_48 = 9 # 48-bit color: 16 bits each for Red, Green, and Blue. Cannot be written to.
     BMM_YUV_422 = 10 # This is the YUV format - CCIR 601. Cannot be written to.
     BMM_BMP_4 = 11 # Windows BMP 16-bit color bitmap. Cannot be written to.
     BMM_PAD_24 = 12 # Padded 24-bit (in a 32 bit register). Cannot be written to.
     BMM_LOGLUV_32 = 13 BMM_LOGLUV_24 = 14
     BMM_LOGLUV_24A = 15 BMM_REALPIX_32 = 16 # The 'Real Pixel' format.
     BMM_FLOAT_RGBA_32 = 17 # 32-bit floating-point per component (non-compressed),
     RGB with or without alpha
     BMM_FLOAT_GRAY_32 = 18 # 32-bit floating-point (non-compressed), monochrome/grayscale
     BMM_FLOAT_RGB_32 = 19
     BMM_FLOAT_A_32 = 20

Reading pixel values from the image:
Annotation 2020-05-12 143904
bmp_storage = bmp.GetStorage()
hdr_pixel = bmp_storage.GetHDRPixel(3000,200)
1. Get reference to the Bitmap‘s BitmapStorage object.
* in this case, writing over the BitmapStorage object we created earlier just to get the BitmapInfo object..
2. Read the pixel value.


When copying and pasting a script from this example, the indentation may not be pasted correctly.



Python for Blender – Batch renaming objects

Blender 2.8 | Python 3.7

Some useful short Python snippets for batch re-naming objects in Blender:

  1. Remove last 4 characters from selected object names:
    import bpy
    objects = bpy.context.selected_objects
    for o in objects: =[:-4]

    Annotation 2020-04-23 202028

  2. Rename all selected objects to a set base name followed by a 3 digit numeric suffix:
    import bpy
    objects = bpy.context.selected_objects
    for (i,o) in enumerate(objects): = "some_base_name_{:03d}".format(i)

    Annotation 2020-04-23 202718

  3. Prefix all selected objects name with their Blender data type like renaming “SomeModel” to “MESH_SomeModel” or for example:
    import bpy
    objects = bpy.context.selected_objects
    for (i,o) in enumerate(objects): = "{}_{}".format(o.type,

    Annotation 2020-04-23 203345


* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Blender 2.8 has a robust batch renaming utility that is invoked by pressing Ctrl + F2 so we don’t have to write scripts to do batch renaming of objects:

Annotation 2020-04-24 174503


Python for Blender – Accessing Mesh Triangles

Python for 3ds max – Select objects of type

3ds max 2020

Continuing this example,
If you need to select objects (nodes) of a certain type i.e. lights, cameras etc.
You can use the INode class’s GetObject() method to get a reference to the node’s object, or “modified object” in 3ds max terms, and use the object’s GetSuperClassID() method to get the integer id representing the object’s superclass.

In addition, the MaxPlus SuperClassIds class contains convenient constants that can be used to avoid having to check and remember the superclasses numeric ids.
See reference here:

An example of a script that selects all light objects in the scene:

from MaxPlus import SuperClassIds
from MaxPlus import SelectionManager

def scene_objects():
   def list_children(node):
      list = []
      for c in node.Children:
         list = list + list_children(c)
      return list
   return list_children(MaxPlus.Core.GetRootNode())

for o in scene_objects():
   obj = o.GetObject()
   if obj.GetSuperClassID() == SuperClassIds.Light:
      SelectionManager.SelectNode(o, False)

* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Python for 3ds max – Mesh manipulation

3ds max 2019

An example of creating a mesh ripple deformation using Python for 3ds max:


Script steps:

  1. Define the effect intensity and a helper point object that will serve as the effect center.
  2. Collapse the object to an Editable-Mesh so its vertices will be accessible by Python.
    Note that the Node‘s Object has to be cast as a TriObject, to access the object’s Mesh data.
  3.  Loop through the Mesh’s vertices, get their world position, and set a new Z position as a sine function of the distance from the effect center.
import math
from MaxPlus import Factory
from MaxPlus import ClassIds
from MaxPlus import INode
from MaxPlus import TriObject
from MaxPlus import Matrix3
from MaxPlus import Point3

# Intensity:
effecr_mult = 1.0

# Effect center:
effector = INode.GetINodeByName('Point001')
effect_pos = effector.GetWorldPosition()

# Prepare object and eccess it's mesh data:
node = INode.GetINodeByName('Teapot001')
new_edit_mesh_mod = Factory.CreateObjectModifier(ClassIds.Edit_Mesh)
node_tm = node.GetWorldTM()
node_pos = node.GetWorldPosition()
obj = node.GetObject()
triobj = TriObject._CastFrom(obj)
mesh = triobj.GetMesh()

# Process the object's vertices:
for i in range(mesh.GetNumVertices()):
     # Get vertex in world space
     vert_pos = mesh.GetVertex(i)
     vert_world_pos = node_tm.VectorTransform(vert_pos)
     vert_world_pos = vert_world_pos + node_pos
     # Get vertex distance from effect center:
     diff_vec = vert_world_pos - effect_pos 
     diff_vec.Z = 0
     dist = diff_vec.GetLength()
     # Set new vertex position:
     mesh.SetVert(i,vert_pos.X,vert_pos.Y,vert_pos.Z + math.sin(dist)*effecr_mult)

* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Related Post:
Python for 3ds max – Animated Mesh

UE4 – Python – Importing assets

Unreal Engine 4.20


Importing assets into a project is done using the import_asset_tasks() function which is a member of the unreal.AssetTools class.
A reference to the AssetTools class is created by calling the get_asset_tools() function which is a member of the unreal.AssetToolHelpers class.
The import_asset_tasks() function requires a list of unreal.AssetImportTask objects as an argument, each unreal.AssetImportTask object in the supplied list represents the import action of a single asset, and contains properties needed for the import operation.
Asset import properties are set using the set_editor_property() function which is called through the AssetImportTask object.
Available asset import properties are listed here:

In the following example a specified texture file is imported into the project and stored in the Content(Game) > Textures folder.
* If the folder doesn’t exist it will be created.

import unreal
AssetTools = unreal.AssetToolsHelpers.get_asset_tools()
AssetImportTask = unreal.AssetImportTask()
AssetImportTask.set_editor_property('filename', "D:\Wood_Red_A.jpg")
AssetImportTask.set_editor_property('destination_path', '/Game/Textures')

The following example imports all the JPG files from folder: D:\ into the project, stores the new assets in Content(Game)\Textures folder and saves them:

from os import listdir
from os.path import isfile, join
import unreal
dir = "D:\\"
files = [f for f in listdir(dir) if isfile(join(dir, f)) and f[-3:]=='jpg']
AssetTools = unreal.AssetToolsHelpers.get_asset_tools()

import_tasks = []
for f in files:
     print join(dir, f)
     AssetImportTask = unreal.AssetImportTask()
     AssetImportTask.set_editor_property('filename', join(dir, f))
     AssetImportTask.set_editor_property('destination_path', '/Game/Textures')
     AssetImportTask.set_editor_property('save', True)


* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.


  1. Get started with Python in UE4
  2. Setting actors locations

UE4 – Python Scripting – how to start

Unreal Engine 4.20

  1. Go to:
    Edit > Plugins > Scripting
    And enable the Python Editor Script Plugin.
    * also recommended to enable Editor Scripting Utilities,
    And Sequencer Scripting plugins
  2. Restart the UE4 Editor.
  3. Open:
    Window > Developer Tools > Output Log
  4. Switch the command-line mode from Cmd to Python, write Python commands and press Enter to execute them:
  5. Or in Cmd mode, write ‘py‘ with a path to a Python script file, and hit Enter to execute the script:



  1. Scripting the Editor using Python:
  2. UE4 Python API reference:



  1. Importing assets
  2. Placing actors

Python for 3ds max – Animated Mesh

3ds max 2019

This is an example of procedurally animating a mesh’s vertices via Python script.


1. The model has to be converted to Editable Mesh before the script is run.
* unless the scrip will be extended to do it.
2. The model must be selected for the script to work.

import MaxPlus
import math
from MaxPlus import INode
from MaxPlus import TriObject
from MaxPlus import SelectionManager
from MaxPlus import Factory
from MaxPlus import Animation
from MaxPlus import Point3
from MaxPlus import Control

ticks_frame = 160

sel = []
for n in SelectionManager.Nodes:
node = sel[0]

#Setup Controllers
obj = node.GetObject()
Tri = TriObject._CastFrom(obj)
mesh = Tri.GetMesh()
num_verts = mesh.GetNumVertices()
mesh_anim = obj.GetSubAnim(0)
pnt_ctrl = Factory.CreateDefaultMasterPointController()
for i in range(num_verts):
    bezp3 = Factory.CreateDefaultPoint3Controller()

for t in range(100):
    time = t * ticks_frame
    for i in range(num_verts):
        vert_anim = mesh_anim.GetSubAnim(i)
        vert_ctrl = Control._CastFrom(vert_anim)
        vert_val = mesh.GetVertex(i)
        vert_val.SetZ(vert_val.GetZ() + math.sin(((Animation.GetTime()*0.5)/(ticks_frame))+i))

* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Python for 3ds max – Mesh manipulation

Blender Python – Make an unselectable object local so it can be selected..

Blender 2.79

If you happen to link an external object that was made unselectable in the original blend file, You will have no interactive way to make it selectable again, or local, or even delete it from the current blend file.

The good news is that it can easily be done by a very short Python script:

import bpy

obj =['the_untouchable_object']

It should also be very easy script a loop that will find all those linked objects,
I will post an example when I’ll have a minute to breathe… 😀

Notepad++ – Show White Space and TAB

Notepad++ 7.5.9

A lot of Python debugging frustration can be avoided by activating the ‘Show White Space and TAB’ option from the View > Show Symbol menu.

This view option displays yellow dots for White Spaces and yellow arrows for TAB indents in the script, and can save precious time locating places where the indentation is wrong.