Skip to content

Instantly share code, notes, and snippets.

@CGLion
Last active August 3, 2021 00:55
Show Gist options
  • Save CGLion/1bda4bb03f49cdd6ae287dbc62a3eefd to your computer and use it in GitHub Desktop.
Save CGLion/1bda4bb03f49cdd6ae287dbc62a3eefd to your computer and use it in GitHub Desktop.
Python for 3ds max - Replace selected objects with objects from an external file
from MaxPlus import FileManager
from MaxPlus import SelectionManager
model_path = r"D:\Models\Some_model.max"
place_holders = []
for o in SelectionManager.Nodes:
place_holders.append(o)
FileManager.Merge(model_path,True,True)
model = SelectionManager.GetNode(0)
for i in range(len(place_holders)):
place_holders[i].SetObject(model.GetObject())
place_holders[i].SetMaterial(model.GetMaterial())
place_holders[i].SetName(model.Name + "_" + str(i))
model.Delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment