Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

maxscript stops showing results until trackbar is moved.

maxscript stops showing results until trackbar is moved.

Anonymous
Not applicable
337 Views
6 Replies
Message 1 of 7

maxscript stops showing results until trackbar is moved.

Anonymous
Not applicable
Hello everyone.

I have this problem and I really don't know why this is happening.

When I use maxscript, and start scripting a position controller using position_script, somehow, at random time it stops working.

Normally when I move the one object, the second object that is scripted and is referenced to the first one moves to - simply reacts to the script.

And then - after some time (random, usually more than 30 min) I can only see the changes when I move the trackbar slider, or when I press "evaluate" in controller script. I can't point out the cause of this. It happens iven with the simpliest script like setting ones object position to another.

Using animation constraints like link, position etc. works fine.

I tried changing some options in viewports and maxscript preferences - no results.
Resetting 3dsmax or restarting it doesn't help. I am using 3ds max 2008 x64. win xp x64.

Only restarting the windows helps, but this is absurd.

Any one know the solution?

Best regards,
mac
0 Likes
338 Views
6 Replies
Replies (6)
Message 2 of 7

Steve_Curley
Mentor
Mentor
Difficult to answer without the script.

I would suggest you create a sample scene which includes the script controller, zip it and attach it to a reply so we can take a look. I've seen that kind of thing before, but it's always been (for me) an issue with the way the script is written.

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

0 Likes
Message 3 of 7

Anonymous
Not applicable
I actually found that this is not the error. It is my fault I guess.

Lets say I have 2 objects. $Box01 and $Box02.

I want the $Box01 to be attached to the $Box02 so when I move the $Box02 in the viewport the $Box01 moves to. I know that I can do that via link constraint but I want it to be scripted.

Here is what I do:

I assign the position_script to the position controller to the $Box01. In the position_script I can simply pass the position of the $Box02 to the $Box01.

But here is the tricky part:
How can I do that via script? I mean without opening script controller properties?

If I write in script editor:

$Box01.position.controller = position_script()
txt = "$Box02.pos"
$Box01.position.controller.script = txt

I can open the $Box01 position script controller dialogue and I will see $Box02.pos

This is partially what I want. I can see the changes in $Box01 position only when I move the trackbar slider. In order to see the changes as I move the $Box02 instantly I need to create some variable in the $Box01 position script controller dialogue and assign a position track of $Box02.

Is there a way to create that variable and assign that track via script? Without opening dialogue boxes?

Thx for response,
mac
0 Likes
Message 4 of 7

Steve_Curley
Mentor
Mentor
That is the cause of your problem though because of not having a variable assigned to a track.

It should be possible to script that - look up IScriptCtrl in the Maxscript Help.

Hint. Add your Max version into your sig - it really helps to know with Maxscript questions.

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

0 Likes
Message 5 of 7

Anonymous
Not applicable
Hi.

My max version is 2008 x64


I figured it out with the variable.

Do you happen to know how the syntax should look like for IScriptCtrl?

Could you post an example of script with assigning a variable using IScriptCtrl, that would be extremely helpful to me. I can't figure how to do this.

Best regards,
mac
0 Likes
Message 6 of 7

Steve_Curley
Mentor
Mentor
I've never tried doing that. There are examples in the help which should get you started. I'll have a play, but I'm rather busy (work wise) the next few days.

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

0 Likes
Message 7 of 7

Anonymous
Not applicable
I figured it out smoehow (there are no examples in the help file and documentation is very hard for people like me - without any programming background etc)

The script creating variables from script editor is:

$Box01.position.controller = position_script() -- assign teh script controller to the position
$Box01.position.controller.IScriptCtrl.AddTarget "newVar" $Box2 -- creates the variable
$B0x01.position.controller.IScriptCtrl.SetExpression "newVar" -- puts the variable to the expression field

The numbers in [] next to $Box2 are the indexes of available controllers that are:

3 stands for transform and 1 stands for position, but 1 is index of available controllers in transform, so 3 is a parent of 1.

Thx anyway,
Best regards,
mac
0 Likes