LayoutFlushGroup Causes Unexpected Changes in Another Group
-
Hello,
I’m encountering an issue when I call self.LayoutFlushGroup(self.SHOT_LIST_GROUP).
After using this function to clear the SHOT_LIST_GROUP, another group in my layout, self.FOOTAGE_GROUP (with its own ID), unexpectedly changes its appearance or position.
Image 1: This shows the layout before calling LayoutFlushGroup. Everything looks correct.
Image 2: This shows the layout after calling LayoutFlushGroup. You can see that FOOTAGE_GROUP has changed unexpectedly.
Has anyone experienced something similar? I suspect there may be some dependency between groups or an issue with how the layout hierarchy is managed.
I would really appreciate any insights, suggestions, or recommended best practices to clear and rebuild a group safely without affecting unrelated groups.
Thank you very much for your time and help!
# 添加位图卡片 def add_bitmap_card(self, uid : int, path : str, display : str= ''): ua = KidooShotManagerUserArea() ua.load_card(path, display) self.bitmapItems.append(ua) self.AddUserArea(uid, c4d.BFH_LEFT | c4d.BFV_TOP) self.AttachUserArea(ua, uid) return ua # 创建Kidoo镜头管理器 def redrawAllKidooShotCards(self): self.LayoutFlushGroup(self.SHOT_LIST_GROUP) # 删除组内容 if self.GroupBegin(self.ID_GROUP_UA_REDRAW, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=0, rows=2, title='重绘卡片组', initw=0, inith=0): for i in range(10): # 加载缩略图 self.add_bitmap_card(uid=self.SHOT_MANAGER_USER_AREA + i, path=r'C:\Users\19252\Desktop\test_image\Anime 3840x2160 BOCCHI THE ROCK! Ryo Yamada Gotou Hitori Nijika I.png', display='#0001') self.GroupEnd() # 明确对应结束此分组 self.LayoutChanged(self.FOOTAGE_GROUP) self.LayoutChanged(self.SHOT_MANAGER_GROUP) # <<<<<<<<<<<<<<<<<Kidoo镜头管理器内容区域>>>>>>>>>>>>>>>>>>>> # 创建Layout 布局函数 def CreateLayout(self): # 窗口初始化设置 self.SetTitle('Kidoo-场景管理器' + f' V.{self.WINDOW_VERSION}' ) # 创建Menu 菜单 self.CreateMenu() # 创建完Menu后,刷新镜头数据 self.Refresh_Kidoo_Shot_Data() # 总体布局 if self.GroupBegin(self.MAIN_GROUP, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=0, rows=0, title="Kidoo-场景装配器",initw=0, inith=0, groupflags=c4d.BFV_GRIDGROUP_ALLOW_WEIGHTS): # ——— 第一次打开时,初始化主组左右列权重:30% / 70% ——— if not hasattr(self, 'main_weights_saved'): # 创建一个 BaseContainer 用于保存主布局的列权重 self.main_weights = c4d.BaseContainer() # 告诉 C4D 这是两列的权重设置 self.main_weights.SetInt32(c4d.GROUPWEIGHTS_PERCENT_W_CNT, 2) # 设置第一列占比:30% self.main_weights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_W_VAL + 0, 30.0) # 设置第二列占比:70% self.main_weights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_W_VAL + 1, 70.0) # 标记已初始化,后续就不会重复设置默认值 self.main_weights_saved = True # 每次布局时,将保存的权重加载到 MAIN_GROUP 上,以保持用户上次的拖拽状态 self.GroupWeightsLoad(self.MAIN_GROUP, self.main_weights) # ——— 左边组:FOOTAGE_GROUP ——— if self.GroupBegin(self.FOOTAGE_GROUP, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=0, rows=2, title="镜头",initw=100, inith=0): border_space_pixels = 3 self.GroupBorderSpace(border_space_pixels, border_space_pixels, border_space_pixels, border_space_pixels) # 设置边框空间 self.GroupBorderNoTitle(c4d.BORDER_BLACK | c4d.BORDER_ACTIVE_1) # 创建控件 self.Kidoo_Shot_Manager_Title() # 列表卡片图片 if self.ScrollGroupBegin(id=self.SHOT_LIST_GROUP, flags=c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, scrollflags=c4d.SCROLLGROUP_VERT, initw=0, inith=0): self.GroupSpace(10, 10) self.GroupBorderNoTitle(c4d.BORDER_ACTIVE_4) self.GroupBorderSpace(5, 5, 5, 5) self.redrawAllKidooShotCards() self.GroupEnd() self.GroupEnd() # ——— 右边组:TAB_GROUP(包含多个子 Tab) ——— if self.TabGroupBegin(self.TAB_GROUP , c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, c4d.TAB_TABS): border_space_pixels = 3 self.GroupBorderSpace(border_space_pixels, border_space_pixels, border_space_pixels, border_space_pixels) # 设置边框空间 self.GroupBorder(c4d.BORDER_BLACK | c4d.BORDER_ACTIVE_1) # 创建SHOP组 if self.GroupBegin(id= self.SCENE_BUILDER_GROUP, flags=c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=1, rows=0, title="场景装配", initw=0, inith=0): # 创建控件 self.Kidoo_Scene_Builder_Title() self.Kidoo_Scene_Builder_Set_Scene() # self.Kidoo_Scene_Builder_Camera() # self.Kidoo_Scene_Builder_Asset() self.GroupEnd() # 创建SHOP组 if self.GroupBegin(id= self.SHOP_GROUP, flags=c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=0, rows=0, title="镜头", initw=0, inith=0): ... self.GroupEnd() # 创建Asset组 if self.GroupBegin(id=self.ASSET_GROUP, flags=c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=0, rows=0, title="资产", initw=0, inith=0): ... self.GroupEnd() self.GroupEnd() self.GroupEnd() return True
-
Hey @Amazing_iKe,
thank you for reaching out to us. With the 2025.3.0 SDK, I just published some new GUI examples, including py-cmd_gui_dynamic_2024, which does exactly what you want to do here.
Without executable code I can only guess (please also keep in mind that we cannot debug full projects for users, for complex issues you should write a boiled down version). But when I look at your code two things stand out to me:
- Unlikely my code example, you already flush your layout when it is created as your
CreateLayout
just callsredrawAllKidooShotCards()
which then callsself.LayoutFlushGroup(self.SHOT_LIST_GROUP)
but that group has not yet been closed at that point inCreateLayout
. - You try to flush a
ScrollGroup
and not aGroup
. They are quite similar, but I am not 100% sure that scroll groups support flushing. That would be at least the first thing I would try when I encounter problems. The fix is simple: Just add a normal group there and then in the dynamic content, simple nest a scroll group into it as the root element. - When
FOOTAGE_GROUP
would be a child ofSHOT_LIST_GROUP
, that would of course also explain it, but it is actually the other way aroundFOOTAGE_GROUP
is the parent. The insertion pointer might be faulty in your case because due to (1) you flush yourSHOT_LIST_GROUP
before it has been fully created, and then the insertion pointer might accidently leak into the parent group or so.
Cheers,
Ferdinand - Unlikely my code example, you already flush your layout when it is created as your
-
@ferdinand Thank you very much for your response and suggestions.
I’ll make sure to follow best practices and provide a minimal, testable code sample when posting questions in the future. I’ll also give embedding a group a try.
Thanks again for your support!