How To ... Develop A Transform Lock Script

This simple tutorial is based on an actual real-world case – a 3ds Max user wanted to create a button to check all 9 checkboxes in the Hierarchy Panel>Link Info > Locks. Unfortunately, he discovered that the MacroRecorder does not output any code for this operation.

Below are the steps required to solve this case including searching the index of this Online Help...

Related Topics:

Defining Macroscripts

General Node Properties

Natural Language:


macroScript LockAllTransforms category:"HowTo"


setTransformLockFlags selection #all



macroScript LockAllTransforms category:"HowTo"


The macroScript will be called LockAllTransforms. To use the script, you can go to Customize... and drag the script from the category "HowTo" to a toolbar, a menu, a quad menu or assign to a keyboard shortcut.

Defining Macro Scripts


setTransformLockFlags selection #all

The Help definition of this method lists it asmapped. This means that it can be applied directly to a collection of objects without an additional MAXScript for loop. In our case we will use the current scene selection – the method will be called for each object in the selection.

General Node Properties


Using the Script

Evaluate the script. To use it, you can use Customize... to drag the script from the category "HowTo" to a toolbar, a menu, a quad menu or to assign to a keyboard shortcut. Select some objects and launch the script – all checkboxes under Hierarchy Panel>Link Info > Locks will be checked.

Where to go from here

As already mentioned, by just replacing the #all keyword with #none, the script can be altered to uncheck all boxes instead. Feel free to write a second macroScript (probably called UnlockAllTransforms) for this operation...

Also note that in 3ds Max 4, the setTransformLockFlags method wasn’t mappable. In case you want your script to be backwards compatible with that version, you could use a for loop to change each object separately. The code would look like

for i in selection do setTransformLockFlags i #all


Some users who did this tutorial in 3ds Max 5 actually went even further and tried to use the general BitArray access to the Lock Flags. Here are some details about the usage of BitArrays in this case.

The setTransformLockFlags method description under General Node Properties explains that there are 9 bits in the BitArray corresponding to the position, rotation and scale locks.

A BitArray is a list of binary values (bits) which can be either True or False. A BitArray is defined by # followed by curly braces {} containing the indices of the True bits separated by commas. For example, #{1,4,7} will set only the X-axis locks of all 3 categories to True.

When multiple bits are set to True, they can be written as the first and last index separated by .., for example #{1..9} defines a BitArray of 9 elements all of which are set to True. It would be equivalent to the #all flag when using with the setTransformLockFlags method. #{} would be equivalent to the #none flag. #{1..3} would only check the first 3 Locks while turning the other 6 off and so on.

Feel free to experiment with the BitArray values and define further macroScripts to set only the Position, the Rotation or the Scale locks.

Back to

"How To" Tutorials Index Page