Notifications
Clear all

[Closed] Renaming a displace modifier

Hi,
1. I was wondering if it is possible to rename a displace modifier via maxscript
2. What does “27980” mean in the maxscript listener
3. I have two displace modifiers on a box but any attempt to set the parameters
only get set on the first one in the list and not the second displace modifier any suggestions?
Renaming them is what first comes to mind but Im lost. NOOB!

modPanel.setCurrentObject myBox.modifiers[5] -- open on 5th modifier
      myBox.displace.strength = 130
      myBox.displace.maptype = 2.0
 modPanel.setCurrentObject myBox.modifiers[6] -- open on 6th modifier
      myBox.displace.strength = 6
      myBox.displace.maptype = 2.0
  I'd really appreciate any advice as searching maxscript help and the forums is getting me nowhere fast.
  
  Thanks
  Luke
3 Replies

Well a lot of stuffing around and I’ve managed to rename the two displacement maps which has solved the main problem still curious about that number that the listener throws up.

The code I used btw to change the names was


modPanel.addModToSelection  (Displace())
mybox.Displace.name = "Displace1"
modPanel.addModToSelection  (Displace())
myBox.Displace.name = "Displace2"
modPanel.addModToSelection  (Noisemodifier())
modPanel.addModToSelection  (Noisemodifier())
modPanel.addModToSelection  (FFD_2x2x2())
max modify mode -- open mod panel
modPanel.setCurrentObject myBox.modifiers[6] -- open on 6th modifier
myBox.turbosmooth.iterations = 3
myBox.turbosmooth.renderIterations = 6
modPanel.setCurrentObject myBox.modifiers[5] -- open on 6th modifier
myBox.displace1.strength = 130.0
myBox.displace1.maptype = 2.0
modPanel.setCurrentObject myBox.modifiers[4] -- open on 6th modifier
myBox.displace2.strength = 6
myBox.displace2.maptype = 2.0

Still got to change the noise mods but here is how I did it.
Once I’ve sorted it all out I’ll try and write the code more efficiently…if I can lol

Luke


(
	-- this function returns the Nth modifier from the given class on the given object if it exist, undefined otherwize
	fn getNthModiferInstance obj modClass n =
	(
		local modInstances = for m in obj.modifiers where isKindOf m modClass collect m
		if n <= modInstances.count then
			modInstances[n]
		else
			undefined
	)
	
	-- Example:
	
	-- first create the starting state
	local myObject = teapot()
	addmodifier myObject (displace())
	addmodifier myObject (displace())
	
	-- now rename the modifiers
	local m1 = getNthModiferInstance myObject displace 1
	local m2 = getNthModiferInstance myObject displace 2
	if m1 != undefined then
		m1.name = "I'm the 1st Displace"
	if m2 != undefined then
		m2.name = "I'm the 2nd Displace"
)

hope this helps

Thats a great help thank you.

Nice site btw
sigh I’ve got a long road ahead of me

Luke