Jump to content

Replacing point helper with and object


alrawli
 Share

Recommended Posts

We have a file with positions of bollards and these positions are marked in Max as Point Helpers and we would like to replace these en masse with a bollard model. Ive got a couple of replace scripts which work with replaceing objects for objects but they dont seem to work with replacing a helper for an object. Does anyone know of any work arounds or scripts out-there?

 

Cheers

 

Al.

Link to comment
Share on other sites

Hmm, couldn't find it online, so i dont remember what the original authors name was (i *think* it was swami), but this works.

 

(

fn objsToProcessAsArray objsToProcess =
(
if classOf objsToProcess==array then
(
	if objsToProcess.count!=0 then return objsToProcess		
	else return undefined									
)

if objsToProcess==undefined then return undefined

if classOf objsToProcess==ObjectSet or classOf objsToProcess==PathName then
(
	objsToProcess=objsToProcess as array
	if objsToProcess.count!=0 then return objsToProcess		-- At least one object in array.
	else return undefined						-- NO objects in array!
)

-- Check for single object passed (and convert to array if true).
local validSuperClasses=#("camera","GeometryClass","helper","light","shape","SpacewarpObject")
local sClassObjsToProcess=(superClassOf objsToProcess) as string
for sClass in validSuperClasses where
	(

		local execStr="superClassOf objsToProcess=="
		execStr += (sClass as string)

		execute execStr
	)
do
(
	return #(objsToProcess)
)

if classOf objsToProcess==SelectionSet then
(
	return (for obj in objsToProcess collect obj)
)

undefined	-- If none of the above checks are true, then 'objsToProcess' was invalid
			-- (e.g. an integer, float, etc.).
)

fn instanceEm objsToProcess:(getCurrentSelection()) =
(

objsToProcess=objsToProcessAsArray objsToProcess
if objsToProcess!=undefined AND objsToProcess.count>1 then
(
	local objMaster, obj

	objMaster=objsToProcess[1]
	for i=2 to objsToProcess.count do
	(
		obj=objsToProcess[i]
		instanceReplace obj objMaster
	)
	select objMaster
)
)
format "test"
instanceEm()
)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...