Script missing Dll when setting spinner controller parameter to custom object

Script missing Dll when setting spinner controller parameter to custom object

andres.hernandezB63FL
Advocate Advocate
1,172 Views
6 Replies
Message 1 of 7

Script missing Dll when setting spinner controller parameter to custom object

andres.hernandezB63FL
Advocate
Advocate

Hi everyone!, 
I really wish that someone could help me with this one.
I reduced my script to the minimum to reproduce the issue I'm facing.
I'm setting an spinner controller parameter to a controller that I created to control the Ik swivel from an object. 
In this very simple example, it creates the an Ik having 2 bones and then a Point where it adds the custom attribute with the spinner in it.
Here is the code:

BoneStart = BoneSys.createBone [0,0,0] [1,0,0] [0,0,1]
BoneStart.length = 100 
BoneEnd = BoneSys.createBone [(BoneStart.length), 0, 0] [1,0,0] [0,0,1]
BoneEnd.length = 4 
BoneEnd.parent = BoneStart

PointCtrl = point box:true deawontop:true cross:true size:100
addModifier PointCtrl (EmptyModifier ())
ikChain = iksys.ikchain BoneStart BoneEnd "IKHiSolver"
ikChain.controller.swivelAngle.controller = linear_float()
ca = attributes IKcontroller
(
	parameters params rollout:IK_rollout
	(
		Swivel type:#angle ui: Swivel
	)
	rollout IK_rollout "IK Swivel" width:162 height:77
	(
		spinner Swivel "Swivel Angle" range:[-1000000,1000000,0] width:100 Align:#Center controller:ikChain.controller.swivelAngle.controller 
	)
)
	
custAttributes.add PointCtrl.modifiers[1] ca



So the problem is that if I save the result scene and then I tried to reload it, Max will ask for a missing dll.
I found that the problem happens when I use the controller directly on the spinner controller parameter and it will only happens if the IK object is in a variable and I'm not calling the actual $ikChain001 for example.

Thanks a lot!

0 Likes
Accepted solutions (2)
1,173 Views
6 Replies
Replies (6)
Message 2 of 7

Swordslayer
Advisor
Advisor
Accepted solution

In your rollout controller assignment, you refer to a variable that's only available when you're executing the original script, otherwise it doesn't exist. Assign the controller directly to the parameter that's connected to the spinner:

 

 

ca = attributes IKcontroller
(
	parameters params rollout:IK_rollout
	(
		Swivel type:#angle ui:Swivel
	)
	rollout IK_rollout "IK Swivel" width:162 height:77
	(
		spinner Swivel "Swivel Angle" range:[-1e6,1e6,0] width:100 Align:#Center
	)
)
	
custAttributes.add PointCtrl.modifiers[1] ca
PointCtrl.modifiers[1].Swivel.controller = ikChain.controller.swivelAngle.controller

 

0 Likes
Message 3 of 7

andres.hernandezB63FL
Advocate
Advocate

Hi Vojtěch, thank you so much, that's just perfect and thank you for the explanation, it has complete sense, I just checked and everything gets clear after the script is expected (as expected :))

0 Likes
Message 4 of 7

andres.hernandezB63FL
Advocate
Advocate

Hi Vojtěch, just one more thing. If I wanted to use one of the variables that are only available when I'm executing the original script but inside the rollout (maybe with a button or something like that), I found that is possible but again, it will break in the new session, so I think I'm having a mess with the variables scope. Could you give me any idea to do that?
Thanks

0 Likes
Message 5 of 7

Swordslayer
Advisor
Advisor
Accepted solution

If you want something available in the CA scope, store it in another parameter. You can store a node/s in a #node/#nodeTab one, weak references and/or assorted MAXWrapper objects in a #maxObject/#maxObjectTab one, strong references inside RefTargContainer that's stored as a #maxObject, and ints/floats/point2/3s/matrices/strings etc in matching parameters. You get the idea.

0 Likes
Message 6 of 7

andres.hernandezB63FL
Advocate
Advocate

Thanks for the answer. I thought about that but I have more than simple variables, I'm using arrays so I need to access to those arrays. Everything is placed in main rollout so I tried even accessing to the outer variables by calling the variables as parameters, for example 

MainRollout.BoneEnd

but the problem is again, the dll problem when loading the new session. 
So, by using the parameters as you suggest, in the CA scope, I can store an array? 
In this example I added the parameter boneStart to store the jointStart, have no I idea if that's the right way to do it:

rollout IKObject "IK Object"
(
	checkbutton startBone "Start Joint" across:2
	checkbutton endBone "End Joint" 
	button buildIK "Build IK" width:70 height:50 offset:[0, 50]
	
	local jointStart
	local jointEnd
	local joints = #()
	
	on startBone changed state do
		if state do
		(
			jointStart = pickObject message:"Select the start bone of the chain"
			startBone.text = jointStart.name
			startBone.checked = off
		)
		
	on endBone changed state do
		if state do
		(
			jointEnd = pickObject message:"Select the end bone of the chain"
			endBone.text = jointEnd.name
			endBone.checked = off
		)
		
	on buildIK pressed do
	(

	select jointEnd
			
	while $ != jointStart do
	(
		append joints $
		select $.parent
	)
		
	PointCtrl = point pos:jointEnd.pos box:true deawontop:true cross:true size:100
	addModifier PointCtrl (EmptyModifier ())
	ikChain = iksys.ikchain jointStart jointEnd "IKHiSolver"
	ikChain.controller.swivelAngle.controller = linear_float()
	ca = attributes IKcontroller
	(
		parameters params rollout:IK_rollout
		(
			Swivel type:#angle ui: Swivel
			BoneStart type:#node default: jointStart
		)
		rollout IK_rollout "IK Swivel" width:162 height:77
		(
			spinner Swivel "Swivel Angle" range:[-1000000,1000000,0] width:100 Align:#Center --controller:ikChain.controller.swivelAngle.controller 
		)
	)
	custAttributes.add PointCtrl.modifiers[1] ca
	PointCtrl.modifiers[1].Swivel.controller = ikChain.controller.swivelAngle.controller
	)
)
CreateDialog IKObject 200 200
	

Thanks again for your help and time

0 Likes
Message 7 of 7

andres.hernandezB63FL
Advocate
Advocate

Thank you for your instructions. I've read more about the parameters and found what where the tab ones for so now is working as expected just by storing all of my outer variables in it's parameter and then, outside the CA, I assign the values for those parameters.
Thank you so much Vojtěch

0 Likes