Перейти к содержимому

3ds Max Copy And Paste Script ❲Pro ✯❳

3ds Max — Copy & Paste Script (Useful Content)

1. Keyboard Shortcut Integration

-- Register with 3ds Max
macroScript EnhancedCopy category:"Custom Tools"
(
    on execute do copySelectedObjects #full
)
-- Assign to Ctrl+Shift+C in Customize UI

The MAXScript Interrogation: Deconstructing the Object

A sophisticated copy-paste script operates by dismantling the scene object into its component parts via MAXScript. In the object-oriented paradigm of 3ds Max, a Teapot is not just a teapot; it is a class instance with properties such as .pos, .rotation, .scale, and .material.

A deep-dive into the code of such scripts reveals a separation of concerns. The script creates a temporary storage buffer (often a global variable or a struct) that holds specific data types.

  1. The Transform Buffer: The script accesses $.transform, which is a 4x3 matrix. By copying only this matrix, the script allows the user to "paste" position and orientation onto an object with different geometry. This effectively decouples where something is from what something is.
  2. The Modifier Stack: One of the most complex aspects of 3ds Max scripting is handling the modifier stack. A robust script does not just copy the object; it iterates through $.modifiers. It captures the class of the modifier and its parameters. When pasting, the script re-instantiates these modifier classes on the target. This is not a binary copy; it is a reconstruction of the history stack.
  3. The Instancing Logic: The script must determine topological relationships. If the user copies a modifier, should the script paste a unique modifier or an instance of the original? In MAXScript, this requires checking instances.getID to ensure that changes to the pasted modifier propagate correctly if instancing is desired, maintaining the parametric integrity of the scene.

Limitations & Workarounds

| Limitation | Workaround | |------------|-------------| | Cannot copy lights/cameras natively | Use instance mode or save as .max snippet | | Animation controllers lost | Store as .xaf file internally | | Cross-version compatibility | Use XML/JSON export instead of binary |

Option 1: Copy/Paste Transform Script (Position, Rotation, Scale)

This script lets you copy the transform of one object and paste it onto another. 3ds max copy and paste script

-- Copy Transform Script
global copyTM = undefined

macroScript copyTransform category:"My Tools" tooltip:"Copy Transform" ( if selection.count == 1 then ( copyTM = selection[1].transform format "Transform copied from: %\n" selection[1].name ) else messageBox "Please select one object to copy transform from." )

macroScript pasteTransform category:"My Tools" tooltip:"Paste Transform" ( if copyTM != undefined and selection.count > 0 then ( for obj in selection do obj.transform = copyTM format "Transform pasted to % object(s)\n" selection.count ) else if copyTM == undefined then messageBox "Nothing copied yet. Use 'Copy Transform' first." else messageBox "Select at least one object to paste transform to." )

How to use:

  1. Select a source object → Run copyTransform
  2. Select target object(s) → Run pasteTransform

The Robust Version (File-Based)

Replace the copyScript function with file I/O:

fn robustCopy =
(
 local tempFile = (getDir #temp) + "\\max_copy_temp.max"
 saveNodes selection tempFile --Saves selected objects to a temp .max file
 print "Saved to temp file. Ready to paste anywhere."
)

fn robustPaste = ( local tempFile = (getDir #temp) + "\max_copy_temp.max" if doesFileExist tempFile do ( mergeMAXFile tempFile #select #promptDups #useMergedMaterialDups ) ) 3ds Max — Copy & Paste Script (Useful Content) 1

This basic script is the foundation of every professional Copy-Paste script on the market.