Notifications
Clear all

[Closed] If clause help

Hi everybody
I have an if clause problem

example
IF (selection.count >0) then ( ) else ( messageBox “There is no objects selected, Please select objects and try again”)

now problem:
so come to think having Bend modifier and i need an If clause like this:

1: If there is a bend modifier on selected objects then ( ) and if there is no bend modifier show this message else( )

2: If the specific modifier has no animation show this message else ( )

Thanks in advance

2 Replies

1:

fn getObjsWithoutBend =
(
	objsWithoutBend = #()
	objs = selection as array
	for i = 1 to objs.count do
	(
		bFound = false
		for j= 1 to objs[i].modifiers.count do
		(
			if ( ( classOf objs[i].modifiers[j] ) == Bend ) then
			(
				bFound = true
			)
		)
		if ( bFound == false ) then
		(
			append objsWithoutBend objs[i]
		)

	)
	return objsWithoutBend
)
getObjsWithoutBend()

I did it this way because its better to not have messageboxes in loops ii my opinion because lets say you have 1000 objects selected and none of them have a Bend modifier, you going to get 1000 messageboxes. instead this returns and array of the objects which dont have a Bend

2 is a little more involved you need to check each of the properties of the bend modifier to have a controller and the keys of that controller ie

if ( selection[1].modifiers.BendAngle.controller != undefined ) then
(
	if ( selection[1].modifiers[1].BendAngle.controller.keys.count > 1 ) then
	(
		-- ITS ANIMATED
	)
)

you can get the properties by

showProperties selection[1].modifiers[1] -- the bend modifier

there is probably a better way but this works
Hope that helps
Dave

Thanks to take time to answer
Thanks Dave
I’m a maxscript beginner user. I couldn’t put your first script in my script

The script is : first creat a box with bend and bendangle animation then copy and paste some (put some distance better), select all then run this script

 IF (selection.count >0) then
     (                        
         theoffset=0
         for o in $ do movekeys o.modifiers[#Bend].BendAngle.controller (theoffset +=5)
     )
                                                         
 else -- If there is no object selected
     (
     messageBox "There is no objects selected, Please select objects and try again"
     )

I put your if clause it worked in one case.when no bendangle animation that works but when you have 4 boxes and one of them doesn’t have bendangle animation it doesn’t work.

====================
By the way Dave
Can i ask you please go to [ http://www.scriptspot.com/3ds-max/scripts/custom-graphic-user-interface-modifier#comment-28227 ] this site to look at ( Custom Graphic User Interface )
I know that creating such things is faraway of my scripting knowledge ,have any idea about where to start it.
Thanks.