Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. Hongzz
    H
    • Profile
    • Following 2
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    Hongzz

    @Hongzz

    0
    Reputation
    3
    Profile views
    3
    Posts
    0
    Followers
    2
    Following
    Joined Last Online

    Hongzz Unfollow Follow

    Latest posts made by Hongzz

    • Differences between menu item execution and execution through the script editor

      Script layout can normally execute the command, but the icon under the menu can not correctly execute the command, why, I am a beginner, please answer the master doubts!d65a5bc6-8f35-4cc7-804a-d55b64f18d35-image.png 7c904fc5-0822-46a2-8763-ed2d4a03f06d-image.png

      Updated by Ilia on 22/05/2024:
      Consolidated consequent messages in a single posting:

      import os
      import c4d
      
      class ImportDialog(c4d.gui.GeDialog):
          BUTTON_ID_BASE = 1000
      
          def __init__(self):
              self.files = []  # 初始化为空列表
      
          def LoadFiles(self):
              startup_path = c4d.storage.GeGetStartupWritePath()
              project_dir = os.path.join(startup_path, 'library', 'scripts', 'spline load', 'projects')
              if not os.path.exists(project_dir):
                  c4d.gui.MessageDialog('项目目录不存在。')
                  return False
      
              self.files = [os.path.join(project_dir, f) for f in os.listdir(project_dir) if f.endswith('.c4d')]
              return True
      
          def CreateLayout(self):
              self.SetTitle("Import C4D Projects")
              if not self.LoadFiles():
                  return False  # 如果加载文件失败,不创建布局
              for index, file in enumerate(self.files, start=self.BUTTON_ID_BASE):
                  filename = os.path.splitext(os.path.basename(file))[0]
                  self.AddButton(index, c4d.BFH_CENTER, name=filename)
              return True
      
      global_dialog_instance = None
      
      def main():
          global global_dialog_instance
          if global_dialog_instance is None:
              global_dialog_instance = ImportDialog()
          global_dialog_instance.Open(c4d.DLG_TYPE_ASYNC, defaultw=400, defaulth=50)
      
      if __name__=="__main__":
          main()
      
      posted in Cinema 4D SDK 2024 python windows
      H
      Hongzz