Learning MaxScript and can't figure out why this script doesn't work.

Learning MaxScript and can't figure out why this script doesn't work.

Anonymous
Not applicable
945 Views
2 Replies
Message 1 of 3

Learning MaxScript and can't figure out why this script doesn't work.

Anonymous
Not applicable

I followed a Joe Gunn tutorial for writing a script to link objects. I then made a dialog box out of it, but it doesn't work. I've attached the script. It's short and simple. Two objects are selected and linked. Any help would be appreciated.

0 Likes
Accepted solutions (1)
946 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor
Accepted solution

The error message in the listener will basically tell you as much, you used myStart and myEnd in the rollout for buttons, use their .object property, not the button itself. Also, pickButtons don't have 'on pressed' event handler, they use 'on picked' but you don't even need it in simple cases like this:

 

try destroyDialog _Link catch()
rollout _Link "Link Objects"
(
	pickbutton myStart "Controllee" autoDisplay:on
	pickbutton myEnd "Controller" autoDisplay:on
	button moveTo "Position"
	button _Go "Link"
	
	on moveTo pressed do
	(
		if isValidNode myStart.object and isValidNode myEnd.object do
			myStart.object.position = myEnd.object.position + [0,0,20]
	)
	on _Go pressed do
	(
		if isValidNode myStart.object and isValidNode myEnd.object do
			myStart.object.parent = myEnd.object
	)		
)
createDialog _Link
Message 3 of 3

Anonymous
Not applicable

Thanks. Appreciate the help

0 Likes