Notifications
Clear all

[Closed] Custom Attributes and Script Controllers

Hi everyone, thank you in advance for your time.

i have added custom attributes to objects called “timeOffset” in integer.
and those objects have script controller, that reference to their individual “timeOffset”.

basically idea was to use the custom attributes to offset the animation.

and that works like a charm. however, when i reopen the file or just opening that file, will through up error saying

“unknown property” timeoffset

and will have all the script controller windows popping up per object.

odd thing is though, the script controller works just fine afterwards, just really annoying i have to click [close] on lot of dialogue window.

my guess is that custom attributes are added before the controllers are calculated?
thats why when loading file, it will through errors because the custom attributes have not been “added?

if that is the case, are there any way around this?

again thank you in advance for any help : )

7 Replies

Hi guys, thanks for the replies. I already have a load of stuff wired which is meaning that I can’t actually wire these parameters!

I already have a dependsOn at the top of my script!

If I manually set the phonemes objects AA attribute to ten and then do a print $Phonemes.Custom_Attributes.AA from within my script, all I get is a 0. This is the whole problem, in that I don’t seem to be able to access the attributes on a different object from within the controller on this one!

I just tried it, and it works fine for me. I can access the parameter through $box01.Custom_Attribute.param1, or just $box01.param1. With the dependsOn, it works in realtime too.

And you can wire multiple properties to the same parameter, you know. The wiring can overlap as much as you want.

What version of max do you have? I have 6.1 here, so maybe something has changed since a previous version.

It’s version 5.1 we have to use here, so maybe thats the problem…

I worked it out – I’m an idiot. I had accidentally put a script controller onto the attribute I was attempting to drive. Once this was set back to a bezier float everything works. Now I just need to get my isProperty stuff working so I dont get loads of errors when the scene with the scripts in opens!

 lo1

maybe you can try setting the .throwOnError property of the controller to false.

If that doesn’t work, you’ll probably need a check inside the controller body if the CA exists or not.

1 Reply
(@alteredgene)
Joined: 11 months ago

Posts: 0

Thanks lo, yes, i could do some safety checking. as only annoyance is when the file is loaded, and it throws up 30 error dialogue, but seems to work just fine.

however, ended up using the “addTarget”. basically added proper variable in the script controller, pointing at the CA. oddly, this seems to work just fine.

scriptCtrl = float_script()
scriptCtrl.AddTarget "timeOff" i.baseObject.wallTimeOffset[1]
scriptCtrl.script = "at time (F-timeOff) $wallMaster.pos.z"
i.position.controller.Zero_Pos_XYZ.Z_Position.controller = scriptCtrl 

again thank you for your suggestion lo, will try that method next time : )

I think the problem is that your script controller is being loaded and evaluated before the other objects that are being referenced even exist, so you get an error initially. Once the scene is loaded everything exists so it works ok.
I generaly just put a try() catch() around them.

1 Reply
(@alteredgene)
Joined: 11 months ago

Posts: 0

thanks floopyb.

that’s what i guessed, which makes sense.

basically they need to calculate the transform controllers before anything to “place” an object in space. and i guess this happens before CA is added to objects when loading.

thanks!