Substitute modifier and vray proxy

Hi all,
I have a large exterior scene with tons of landscaping. I have the landscape plan in CAD format and all the plant symbols are blocks. When I import the cad file into max, all the blocks are instanced. Normally, I’d use the substitute modifier on the block to replace all instances of the block with the correct 3d plant, but it seems that in Max 9, the substitute modifier won’t let me select the proxy as the substitute object. Anyone know a way around this?

I know I can use clone and align, but I have hundreds of instances and would like a quicker way. I remember seeing a tutorial on this somewhere but I can’t seem to find it now.

Any help would be appreciated. Thanks.

Give this a go - unfortunately on max 8 here so not sure if it’ll error or not.

-- Feed in an array of objects to replace and an array of objects to replace with

Function replaceObjects objectsToReplace newObjs =
(	
	if (newObjs.count != 0) then -- If there is a tree object selected then start replacing the nulls with trees
	(

		if (newObjs.count == 1) then -- selection count is one - replace all of the nulls with one type of tree
		(

			newObj = newObjs[1]

			for i = 1 to objectsToReplace.count do
			(
				newObj = instance newObj
				newObj.pos = objectsToReplace[i].pos
				-- newTree.boxmode = on
				delete objectsToReplace[i]
			)

		) else	( -- selection count is more than one so randomly pick a tree to use.

			newObjsCount = newObjs.count

			for i = 1 to objectsToReplace.count do
			(
				newObj = instance newObjs[random 1 newObjsCount]
				newObj.pos = objectsToReplace[i].pos
				-- newTree.boxmode = on
				delete objectsToReplace[i]
			)

		) -- End else

	)	-- End first if

)

-- Globals -----------------------------------------------------------------------------------------------------------------------------

global replaceArray = #()
global newObjArray = #()

buttonWidth = 200
buttonAlign = #right

-- End Globals -------------------------------------------------------------------------------------------------------------------------

rollout objectReplacer "Object replacer"

(

	group "Set source objects"	
	(

		button defineObjsToReplace "Set objects to replace" width:buttonWidth align:buttonAlign
		button defineNewObjs "Set new objects" width:buttonWidth align:buttonAlign

	)

	group "Set replace options"
	(
		spinner xScale "X scale randomness" range:[0,100,10] type:#float
		spinner yScale "Y scale randomness" range:[0,100,10] type:#float
		spinner zScale "Z scale randomness" range:[0,100,10] type:#float

		spinner xRot "X Rotation randomness" range:[0,100,10] type:#float
		spinner yRot "Y Rotation randomness" range:[0,100,10] type:#float
		spinner zRot "Z Rotation randomness" range:[0,100,10] type:#float
	)

	button replaceIt "Replace objects" width:buttonWidth align:buttonAlign

	on defineObjsToReplace pressed do
	(

		if selection.count != 0 then
		(
			replaceArray = selection as array
			replaceObjNames = ""

			for i = 1 to replaceArray.count do
			(
				replaceObjNames += replaceArray[i].name + ","
			)

			defineObjsToReplace.text = substring replaceObjNames 1 30

		)		
	)

	on defineNewObjs pressed do
	(

		if selection.count != 0 then
		(
			newObjArray = selection as array
			newObjNames = ""

			for i = 1 to newObjArray.count do
			(
				newObjNames += newObjArray[i].name + ","
			)

			defineNewObjs.text = substring newObjNames 1 30

		)		
	)

	on replaceIt pressed do
	(

		replaceObjects replaceArray newObjArray

	)

)

createDialog objectReplacer width:300

Thanks for the script! Unfortunately, I got an error:

-- Type error: CreateDialog requires RolloutClass, got: undefined

I’m mascript illiterate, so if anyone out there knows how to fix this for Max 9, I’d appreciate it. Lele, you there? :wink: