Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Scripted modifier

6 REPLIES 6
Reply
Message 1 of 7
ztravnicky
618 Views, 6 Replies

Adding Scripted modifier

Having this script in scripts/startup (script.ms file)

 

plugin modifier modifier_B
name:"B"
classID:(genClassID returnValue:true)
(
	rollout b "TestB"(
		button btnB "ADD A"
		
		fn addA obj = (
			addmodifier obj (modifier_A())
		)
		
		on btnB pressed do (
			for o in objects do (
				addA o 
			)
		)
	)
)

plugin modifier modifier_A
name:"A"
classID:(genClassID returnValue:true)
(
	rollout ra "TestA"(
		button btnA "OK"
		
		on btnA pressed do (
			print "Modifier A"
		)
	)
)

 

When hitting buton "TestB" is causing an error (undefined modifier), even the modifiers should be global! Changing the order will fix this error. Why is this happening? Is it BUG with the chance to be fixed soon? It behaves the same way in all version of MAX.

 

6 REPLIES 6
Message 2 of 7
Steve_Curley
in reply to: ztravnicky

Modifier_A is undefined as far as modifier_B is concerned, or rather it's not defined within the rollout code. You need a "forward reference".
See http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_608825CD_D025_4054_91E2_2562A6AB31C...

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 3 of 7
ztravnicky
in reply to: Steve_Curley

I'm sorry, but this code is not giving success... Am I missing something?

 

plugin modifier modifier_B
name:"B"
classID:(genClassID returnValue:true)
(
	local modifier_A
	
	rollout b "TestB"(		
		button btnB "ADD A"
		
		fn addA obj = (
			addmodifier obj (modifier_A())
		)
		
		on btnB pressed do (
			for o in objects do (
				addA o 
			)
		)
	)
)

plugin modifier modifier_A
name:"A"
classID:(genClassID returnValue:true)
(
	rollout ra "TestA"(
		button btnA "OK"
		
		on btnA pressed do (
			print "Modifier A"
		)
	)
)

 

Message 4 of 7
Steve_Curley
in reply to: ztravnicky

Try putting it inside the rollout, after the rollout b "TestB"( line.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 5 of 7
ztravnicky
in reply to: Steve_Curley

I already did...

Did you try and it worked for you?

Message 6 of 7
Steve_Curley
in reply to: ztravnicky

Nope, because I've not played with that kind of scripting before, but almost every error of that kind is pretty much always down to not following the info on the linked page exactly. Almost guaranteed - and there's rollout code in your example...

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 7 of 7
Steve_Curley
in reply to: Steve_Curley

Ok, took a while to understand what's going on here.
The "forward declaration" does need to be inside the rollout code, but because both modifiers are being created globally the declaration has to be "global" not "local".

Also, I think you should change both of the classID statements to be actual class IDs not random ones. Having them random will cause errors if you execute the script twice because you'll get "Runtime error: Plugin redefinition: Cannot change ClassID".

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report