Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

max script look

Hi,
In case this is the wrong forum to be asking for max script help I'd like to apologize and ask moderators to the correct section.

I am a max script newbie and I'm trying to make a loop that iterates through selected objects and increments a specified property by 1 or 5 according to the name suffix (Object_01,Object_02: 01, 02).

01 - don't increment 1*property
02 - multiply property by 2 etc

This is what I've got so far:

for i = 1 to selection.count do
(
selection.property = i*getProperty
)

Replies

  • monster
    Offline / Send Message
    monster polycounter
    I was a little confused by your description. You said increment (which usually means add) by 1 or 5, but in your example it looks like you are multiplying by the suffix.

    Assuming you want to multiply by the suffix in the name this should work.
    --LOOP THROUGH SELECTION
    for obj in selection do
    (
    	--FILTER OBJECTS THAT HAVE AN UNDERSCORE IN THE NAME
    	if matchpattern obj.name pattern:"*_*" ignoreCase:true do
    	(
    		--SEPERATE THE NAME INTO AN ARRAY USING UNDERSCORE
    		--"OBJECT_01" WILL BECOME #("OBJECT","01")
    		nameParts = filterString obj.name "_"
    		
    		--THE LAST VALUE OF THE NAME WILL PROVIDE THE MULTIPLIER
    		obj.property *= (nameParts[nameParts.count] as number)
    	)
    )
    
Sign In or Register to comment.