I am addiong to this thread hence it is related ... feel free to fork
I am trying to only display a dropdown on certain rows ... is that possible ....?
Here is a minimal dummy plugin where I only want to show the dropdown on "stp" files ....
even though the dropdown gets no content it is still displayed ....
thank you
import c4d
PLUGIN_ID = 12345678
PLUGIN_NAME = "ListView Dropdown Prototype"
ID_TREE_VIEW = 1000
ID_FILE_NAME = 1001
ID_IMPORT_OPTION = 1002
ID_IMPORT_OPTION_DEFAULT = 1100
ID_IMPORT_OPTION_HIGH = 1101
ID_IMPORT_OPTION_MEDIUM = 1102
ID_IMPORT_OPTION_LOW = 1103
dummyfile_list = ["hud.stp", "material_reference.wrl", "front_axle.stp", "body.wrl", "wheel_variant.stp"]
class DummyFile:
def __init__(self, file_name, import_option="Default"):
self.file_name = file_name
self.import_option = import_option
class DummyFileListView(c4d.gui.TreeViewFunctions):
def __init__(self, dialog):
self.dialog = dialog
self.files = [DummyFile(file_name) for file_name in dummyfile_list]
def GetFirst(self, root, userdata):
return self.files[0] if self.files else None
def GetNext(self, root, userdata, dummy_file):
current_index = self.files.index(dummy_file)
next_index = current_index + 1
return self.files[next_index] if next_index < len(self.files) else None
def GetDown(self, root, userdata, dummy_file):
return None
def GetId(self, root, userdata, dummy_file):
return id(dummy_file)
def GetName(self, root, userdata, dummy_file):
return dummy_file.file_name
def IsSelected(self, root, userdata, dummy_file):
return False
def GetColumnWidth(self, root, userdata, dummy_file, column_id, area):
if column_id == ID_FILE_NAME:
return area.DrawGetTextWidth(dummy_file.file_name) + 24
if column_id == ID_IMPORT_OPTION:
return 120
return 96
def GetDropDownMenu(self, root, userdata, dummy_file, column_id, menu_info):
if column_id != ID_IMPORT_OPTION:
return
# this is logical but does not do the trick ....
if not dummy_file.file_name.lower().endswith(".stp"):
return
options = {
ID_IMPORT_OPTION_DEFAULT: "Default",
ID_IMPORT_OPTION_HIGH: "High",
ID_IMPORT_OPTION_MEDIUM: "Medium",
ID_IMPORT_OPTION_LOW: "Low",
}
for option_id, label in options.items():
menu_info["menu"].SetString(option_id, label)
menu_info["entry"] = next(
option_id for option_id, label in options.items()
if label == dummy_file.import_option
)
def SetDropDownMenu(self, root, userdata, dummy_file, column_id, entry):
if column_id != ID_IMPORT_OPTION:
return
#this is logical but does not do the trick ....
if not dummy_file.file_name.lower().endswith(".stp"):
return
options = {
ID_IMPORT_OPTION_DEFAULT: "Default",
ID_IMPORT_OPTION_HIGH: "High",
ID_IMPORT_OPTION_MEDIUM: "Medium",
ID_IMPORT_OPTION_LOW: "Low",
}
dummy_file.import_option = options.get(entry, dummy_file.import_option)
self.dialog.tree_view.Refresh()
class ListViewDropdownDialog(c4d.gui.GeDialog):
def __init__(self):
self.tree_view = None
self.file_list_view = DummyFileListView(self)
def CreateLayout(self):
self.SetTitle(PLUGIN_NAME)
tree_view_settings = c4d.BaseContainer()
tree_view_settings.SetBool(c4d.TREEVIEW_BORDER, c4d.BORDER_THIN_IN)
tree_view_settings.SetBool(c4d.TREEVIEW_HAS_HEADER, True)
tree_view_settings.SetBool(c4d.TREEVIEW_HIDE_LINES, True)
tree_view_settings.SetBool(c4d.TREEVIEW_RESIZE_HEADER, True)
tree_view_settings.SetBool(c4d.TREEVIEW_FIXED_LAYOUT, True)
tree_view_settings.SetBool(c4d.TREEVIEW_ALTERNATE_BG, True)
if c4d.GetC4DVersion() >= 24000:
tree_view_settings.SetInt32(c4d.TREEVIEW_VERTICAL_SPACE, 4)
self.tree_view = self.AddCustomGui(ID_TREE_VIEW, c4d.CUSTOMGUI_TREEVIEW, "", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 500, 220, tree_view_settings, )
if not self.tree_view:
return False
layout = c4d.BaseContainer()
layout.SetLong(ID_FILE_NAME, c4d.LV_TREE)
layout.SetLong(ID_IMPORT_OPTION, c4d.LV_DROPDOWN)
self.tree_view.SetLayout(2, layout)
self.tree_view.SetHeaderText(ID_FILE_NAME, "Dummy file")
self.tree_view.SetHeaderText(ID_IMPORT_OPTION, "STP import option")
self.tree_view.SetRoot(self.tree_view, self.file_list_view, None)
return True
def InitValues(self):
self.tree_view.Refresh()
return True
class ListViewDropdownCommand(c4d.plugins.CommandData):
def __init__(self):
self.dialog = ListViewDropdownDialog()
def Execute(self, document):
return self.dialog.Open(
c4d.DLG_TYPE_ASYNC,
PLUGIN_ID,
defaultw=520,
defaulth=280,
)
if __name__ == "__main__":
c4d.plugins.RegisterCommandPlugin(
id=PLUGIN_ID,
str=PLUGIN_NAME,
info=0,
icon=None,
help="TreeView dropdown.",
dat=ListViewDropdownCommand(),
)





![2025-10-27-Cinema 4D 2025.2.1 - [Untitled 1 _] - Main_001066.png](/forum/assets/uploads/files/1761567924411-2025-10-27-cinema-4d-2025.2.1-untitled-1-_-main_001066.png)
