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

    ImportSymbols with single file didn't return as expect.

    Bugs
    windows python 2025
    2
    6
    585
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DunhouD
      Dunhou
      last edited by

      Hi community,

      I found the mxutils.ImportSymbols can not work with single file. Is this is a bug?

      win 11 + 2025.2

      Cheers~
      DunHou

      import c4d
      from pathlib import Path
      from mxutils import ImportSymbols
      from pprint import pp
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      # replace a file path
      c4d_symbol = r".....c4d_symbols.h"
      
      def main() -> None:
      
          # the file is true exists
          print(Path(c4d_symbol).exists())
          
          symbols_A = ImportSymbols(str(c4d_symbol), output=dict)
          pp(symbols_A) # return {}
      
          symbols_B = ImportSymbols(str(Path(c4d_symbol).parent), output=dict)
          pp(symbols_B) # return a dict with symbols
      
          symbols_C = ImportSymbols(str(Path(c4d_symbol).parent))
          pp(symbols_C) # return None
      
      if __name__ == '__main__':
          main()
      

      https://boghma.com
      https://github.com/DunHouGo

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @Dunhou
        last edited by ferdinand

        Hey @Dunhou,

        Thank you for reaching out to us. Sorry for the delay, everything is happening at once here right now and I am rotating on the spot 👨‍🏭.

        I quickly checked your example, and you are right, some regression happened there. That symbols_C returns None is correct, as passing the default None for output should place the symbols in the enclosing scope of the function call. I.e., when your c4d_symbol (which btw can be any header file, not just a c4d_symbols.h) would contain enum blah { BOB_IS_YOUR_UNCLE = 42}, you should be able to simply write print(BOB_IS_YOUR_UNCLE) and it then printing 42. But that is not working anymore. And symbols_A is also faulty.

        I will have a look what heck broke there, at first glance it is not obvious to me. I think Maxime touched symbol parsing not too long ago, because the parser missed some symbols in the C++ API (this mechanism is used to auto-expose parts of the C++ API to Python), maybe this broke things, I will have to see.

        For now, I would recommend to use the case which is working. I have moved this topic into bugs and hopefully can have a look next week.

        Cheers,
        Ferdinand

        PS: Your MRD weight thingy is not forgotten, I will hopefully cross that off by the end of the week.

        MAXON SDK Specialist
        developers.maxon.net

        ferdinandF 1 Reply Last reply Reply Quote 0
        • ferdinandF ferdinand moved this topic from Cinema 4D SDK on
        • ferdinandF
          ferdinand @ferdinand
          last edited by ferdinand

          Hey,

          sorry for the long turnaround. So, I had a look at the code, and this works as intended.

          path (str) – The path within which header files should be discovered and parsed.

          I got a bit confused by your pathlib shenanigans. So, the bottom line is that the function I myself wrote (lol), does not support passing a file as an input but only directories. I will add a little check to throw a more verbose error, because now this just silently fails when trying to traverse that path.

          We could think about adding the option to parse only a file, but that would be up to Maxime, as he owns the symbol parser backend.

          Cheers,
          Ferdinand

          edit: In future versions (not the next) this will now fail more verbosely when providing a non-directory path or a path that does not exist.

          E:g.:

          import c4d
          from mxutils import ImportSymbols
          from pprint import pp
          
          doc: c4d.documents.BaseDocument  # The currently active document.
          op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
          
          # replace a file path
          c4d_symbol = r"/Users/f_hoppe/git/sdk/plugins/doc.python.github/plugins/py-cmd_gui_resources_2024/res/"
          
          def main() -> None:
          
              symbols_A = ImportSymbols(str(c4d_symbol), output=dict)
              pp(symbols_A) # return {}
          
              symbols_C = ImportSymbols(str(Path(c4d_symbol)))
              pp(symbols_C) # return None
          
              print(ID_PLUGIN)
          
          if __name__ == '__main__':
              main()
          
          {'__DUMMY__': 2006,
           'ID_PLUGIN': 1065655,
           'IDC_VALUE_A': 2003,
           'IDC_VALUE_B': 2005,
           'IDD_VALUES': 2000,
           'IDS_PLUGIN_HELP': 1001,
           'IDS_PLUGIN_NAME': 1000,
           'IDS_VALUE_A': 2002,
           'IDS_VALUE_B': 2004,
           'IDS_VALUES': 2001}
          {'__DUMMY__': 2006,
           'ID_PLUGIN': 1065655,
           'IDC_VALUE_A': 2003,
           'IDC_VALUE_B': 2005,
           'IDD_VALUES': 2000,
           'IDS_PLUGIN_HELP': 1001,
           'IDS_PLUGIN_NAME': 1000,
           'IDS_VALUE_A': 2002,
           'IDS_VALUE_B': 2004,
           'IDS_VALUES': 2001}
          None
          1065655
          

          MAXON SDK Specialist
          developers.maxon.net

          DunhouD 1 Reply Last reply Reply Quote 0
          • DunhouD
            Dunhou @ferdinand
            last edited by

            Hey @ferdinand,

            Is there any deficiency in pathlib ? I just think its writing style is more convenient and it produces less code. Lazy me🤡

            @ferdinand said in ImportSymbols with single file didn't return as expect.:

            does not support passing a file as an input but only directories

            I'm a bit confused, does this mean that ImportSymbols only support directories, but the documentation says that files can be passed for parsing, or did I misunderstand again...
            9164e957-59e9-4433-b901-f7298d92fed5-PixPin_2025-06-12_10-39-10.png
            Cheers~
            DunHou

            https://boghma.com
            https://github.com/DunHouGo

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              You are right, that is a bit odd, either there is regression, or I mixed something up with the code example. In any case, we will either add back singular file support or change the example.

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • ferdinandF
                ferdinand
                last edited by

                FYI: This has been fixed and will be shipped in a future version of Cinema 4D.

                MAXON SDK Specialist
                developers.maxon.net

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post