Bad Thunk error when batch creating attribute definitions


#1

Hey all,

I’m building a rigging tool that will set up some limb features - ik switching, pose mirroring ect. I have all of the tools working fine, I’m just struggling with getting them all wrapped up together in a configurable UI.

I have a dialog box to configure the tools & depending on what ones are selected, the script will roll through an array of attribute definitions & add them to a defined object.

Problem I’m having is that I’d originally written these tools into a single attribute definition that is executed by a function, worked fine. Now they’re all defined as individual attributes - so they can be optional. When running the function to define all the attributes I get a really ambiguous error…

"

MAXScript Scripted plugin local init Exception

– Runtime error: Bad free thunk local member index when accessing local: armOrLegCA

OK

"

What does this even mean?

The variable armOrLegCA is a boolean value that is defined locally within the function - using a parameter passed in at function call.

The error occurs on the second attribute definition within the attribute creation function, so that value of armOrLegCA has already been accessed and used fine (it is only ever modified prior to the function call).


#2

Resolved it!

Classic case of a fundamental misunderstanding of scope & how variables should be accessed within functions & attribute definitions.

facepalm