Xref to link only the geometries using maxscript


I want to link geometries from 3ds max files which have lights and cameras. I found code to link all assets from a 3ds Max file. I am stuck with linking only a specific type from a file. Is there a way to do this?

Here is the code so far,

obj_names = getMAXFileObjectNames "filename.max"
xref_objs = #()
for obj in obj_names do(
	if matchpattern obj pattern:"Cam*"ignoreCase:false do continue
	if matchpattern obj pattern:"VRayLight*"ignoreCase:false do continue
	append xref_objs obj

xrefs.addnewXrefObject "filename.max" xref_objs
objXRefMgr.getAutoUpdate = true

The above code works for most cases but it is not reliable when the linking file doesn’t follow a pattern in cameras and lights.


returns only the name of the objects inside “filename.max”. So you can’t use the obj_names to check the type of the objects(geometry, shape, helpers, etc.). Maybe I am wrong but the only way to do what you want using getMAXFileObjectNames is the name of the objects to “show” the type of the objects.


Hi miauu,

I understand that getMAXFileObjectNames gives the names of the objects in the file. Is there any other way to link specific type of objects(geometry, shape, helpers, etc)?


The ugly way:
1- save your current scene
2- load the “filename.max”
3- check objects, names, types, etc and save the info you need
4- load your original scene and link the object you need(you already have all info about the objects inside “filename.max”)


the less ‘ugly’ way:

  1. x-ref the file you need
  2. find all objects you need to load in xrefscene tree
  3. merge all that you need
  4. delete x-ref file

the only problem with this technique is that you lose your Undo history (but it happens any way when you x-ref (or merge) any scene or objects)


Is there no way to select particular type of objects like we select in UI?