Notifications
Clear all

[Closed] for loop positioning objects

Hi everyone, i am very new to maxscript and need some help with an example I made up to help me become better acquianted. I hope this is very simple. I created and placed several point helpers in a scene. Then I created just one plane which I named Impactflash. All I want to do is create several instances of this Impactflash plane geometry and place them at each point helper. Also I want to add the currently active material to those planes. Please help me understand how to go about achieving such a thing. This is what I have so far.

delete $ImpactFlash0* //—-deletes duplicates when the script is re-run
myPointers = $point*
for i = 1 to 6 do instance $ImpactFlash
myImpactFlashes = $ImpactFlash* as array
myImpactFlashes.material = medit.getCurMtl()

for i in myImpactFlashes do (

 myCounter = 0
 myImpactFlashes[myCounter+=1].pos = myPointers[myCounter+=1].pos

)

1 Reply

A couple of things.

  • you can’t use “//” to comment in maxScript, so you’re going to get an error in the very first line (the “–” is all you need)
  • I’d recommend not using the current material as it limits when you can use this script. impactFlash’s material will automatically be on all the instances.
  • you can do this in a single for loop:

delete $ImpactFlash0* ----deletes duplicates when the script is re-run
myPointers = $point* 

for pt in myPointers do (
	impact = instance $impactFlash
	impact.material = medit.getCurMtl() -- only if this mat is different from what's on the impactFlash
	impact.pos = pt.pos
)