manim icon indicating copy to clipboard operation
manim copied to clipboard

Problems happend when trying to transform a VGroup object to another VGroup object

Open ttzytt opened this issue 3 years ago • 0 comments

Describe the error

I have two VGroup objects, which consisting of other VGroups and Mobjects, when I trying to apply a ReplacementTransformation to these two VGroup objects, some errors happend

Code and Error

Code:

        case_1_scene = VGroup()
        case_1_scene.add(
                        case_1_vised_gird,
                        new_line,
                        case_1_explaination,
                        case_num_txt,
                        left_plug,
                        right_plug,
                        show_no_plug_on_left_right
                        )
        
        
        del visited_grid_id
        del vgrp_grid_line_list
        vgrp_grid_line_list = (creat_grid_line(5, 5, 1, color=BLUE_E))[1]
        case_1_overall_grid = (creat_blocked_grid_by_id(4,4,1,1,2))[1]
        case_1_overall_vised_gird = (creat_visited_grid(4,4,1,
                                                *(tuple(range(1,10))),
                                                color=GREEN_E,
                                                fill_color=GREEN_E,
                                                fill_opacity=0.6
                                                ))[1]
        case_1_overall_effect = VGroup(
                            vgrp_grid_line_list,
                            case_1_overall_grid,
                            case_1_overall_vised_gird
        )
        
        self.play(ReplacementTransform(case_1_scene, case_1_overall_effect))

If I change the code in the last few lines to this:

self.play(ReplacementTransform(case_1_scene, vgrp_grid_line_list))
self.play(Write(case_1_overall_effect))

Then it will run properly, and their will be a similar effect, but I just confused about that error

Error:

Traceback (most recent call last):
  File "C:\Users\ZYT20\AppData\Local\Programs\Python\Python38\Scripts\manimgl-script.py", line 33, in <module>
    sys.exit(load_entry_point('manimgl', 'console_scripts', 'manimgl')())
  File "e:\manim\manim\manimlib\__main__.py", line 25, in main
    scene.run()
  File "e:\manim\manim\manimlib\scene\scene.py", line 76, in run
    self.construct()
  File "manim题解.py", line 431, in construct
    self.play(ReplacementTransform(case_1_scene, case_1_overall_effect))
  File "e:\manim\manim\manimlib\scene\scene.py", line 410, in wrapper
    func(self, *args, **kwargs)
  File "e:\manim\manim\manimlib\scene\scene.py", line 471, in play
    self.progress_through_animations(animations)
  File "e:\manim\manim\manimlib\scene\scene.py", line 450, in progress_through_animations
    animation.interpolate(alpha)
  File "e:\manim\manim\manimlib\animation\animation.py", line 114, in interpolate
    self.interpolate_mobject(self.rate_func(alpha))
  File "e:\manim\manim\manimlib\animation\animation.py", line 126, in interpolate_mobject
    self.interpolate_submobject(*mobs, sub_alpha)
  File "e:\manim\manim\manimlib\animation\transform.py", line 105, in interpolate_submobject
    submob.interpolate(start, target_copy, alpha, self.path_func)
  File "e:\manim\manim\manimlib\mobject\types\vectorized_mobject.py", line 733, in interpolate
    super().interpolate(mobject1, mobject2, alpha, *args, **kwargs)
  File "e:\manim\manim\manimlib\mobject\mobject.py", line 1289, in interpolate
    self.data[key][:] = func(
ValueError: could not broadcast input array from shape (6,1) into shape (3,1)

Environment

OS System: Windows 10 manim version:manimgl python version:3.8.6

ttzytt avatar Oct 23 '21 23:10 ttzytt