Home Website Youtube GitHub

Can't create this chain_ik_spline

I can’t create chain_IK_spline_variable_FK_stack_01. Controllers are created but no joints.

I get this in the script editor:

Objects : chain_C0 (chain_IK_spline_variable_FK_stack_01)
# Traceback (most recent call last):
#   File "C:\mgear4\release\scripts\mgear\shifter\guide_manager.py", line 70, in build_from_selection
#     rg.buildFromSelection()
#   File "C:\mgear4\release\scripts\mgear\shifter\__init__.py", line 261, in buildFromSelection
#     self.build()
#   File "C:\mgear4\release\scripts\mgear\shifter\__init__.py", line 295, in build
#     self.processComponents()
#   File "C:\mgear4\release\scripts\mgear\shifter\__init__.py", line 519, in processComponents
#     comp.stepMethods[i]()
#   File "C:\mgear4\release\scripts\mgear\shifter\component\__init__.py", line 150, in step_00
#     self.setRelation()
#   File "C:\mgear4/release/scripts/mgear/shifter_classic_components\chain_IK_spline_variable_FK_stack_01\__init__.py", line 470, in setRelation
#     fk_each = self.fk_ctl[(i + 1) * every_each]
# TypeError: list indices must be integers or slices, not float

Thank you for the report. I was able to reproduce the same bug on my end. I’ve already reported the issue on GitHub, fixed it, and submitted a pull request.

Module bug fix: chain_IK_spline_variable_FK_stack_01 by joji2468ng · Pull Request #326 · mgear-dev/mgear4 (github.com)

However, if you can’t wait for the issue to be fixed with the accepted pull request, you can manually resolve it by going to the file __init__.py for chain_IK_spline_variable_FK_stack_01 and making the necessary correction on line 464.

# TypeError: list indices must be integers or slices, not float

# Wrong line
every_each = len(self.fk_ctl) / (len(self.ik_ctl) - 1)
# Correct line
every_each = len(self.fk_ctl) // (len(self.ik_ctl) - 1)

The wrong line generates a float value as a result, it should be an integer. To fix this, use // operator for floor division instead of /. It divides the left operand by the right operand and returns the largest integer value that is less than or equal to the division result. In other words, it divides and then rounds down to the nearest whole number.

1 Like