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. Cankar001
    3. Topics
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 21
    • Best 2
    • Controversial 0
    • Groups 0

    Topics created by Cankar001

    • C

      Retrieve the current Unit and listen to changes

      Cinema 4D SDK
      • c++ s24 • • Cankar001
      12
      0
      Votes
      12
      Posts
      868
      Views

      ferdinandF

      Hey @Cankar001,

      Good to hear that you found your solution! One minor thing - you should avoid ApplicationOutput in production code, as it leads to console spam which we want to avoid in Cinema 4D. Using it in test code is fine. See Debug and Output Functions for alternatives.

      An even better way to do what you did in your code would be to use error handling. E.g., your code could look like this:

      // Your original function, I turned this into a function using our error system, indicated by the // Result<T> return type. static maxon::Result<maxon::Float> GetCurrentUnitScale(const BaseDocument* const document) { // The error scope handler for this function, i.e., all error returns exit through this handler. iferr_scope; // When there is no document, we return an error. When printed, this will then print the error // message and the source code location, e.g., myfile.cpp:123. if (!document) return maxon::NullptrError(MAXON_SOURCE_LOCATION, "Invalid document pointer."_s); // Your code goes here. // ... return 1.0f; } // A function calling this function which does use error handling itself. static maxon::Result<void> Foo(const BaseDocument* const document) { iferr_scope; // Call the function and return, i.e., propagate the error upwards when there is one. const maxon::Float unitScale = GetCurrentUnitScale(document) iferr_return; // voids in the Result<T> return type are returned with maxon::OK. return maxon::OK; } // A function calling this function which does not use error handling itself, i.e., the error // must terminate here. static bool Bar(const BaseDocument* const document) { // Here we use a manual scope handler to terminate the error chain. You have often to do this in // Cinema API (e.g., ObjectData::GetVirtualObjects), as methods there are not error handled // opposed to the Maxon API. iferr_scope_handler { // Print a debug message with the passed in error #err and the name of this function. And // force a debugger to halt when some condition is met. WarningOutput("@ failed with error: @"_s, MAXON_FUNCTIONNAME, err); if (someErrorCondition) DebugStop(); return false; }; // Call the function (we still have to handle the error with an iferr_return), and then let it // terminate in our manual scope handler. const maxon::Float unitScale = GetCurrentUnitScale(document) iferr_return; return true; }

      Cheers,
      Ferdinand

    • C

      Making changes to the document through a websocket

      Cinema 4D SDK
      • windows s24 c++ • • Cankar001
      6
      0
      Votes
      6
      Posts
      500
      Views

      C

      @m_adam Thank you very much for your help in the last days! This worked as well as expected πŸ˜„

    • C

      WebSocket usage in C++

      Cinema 4D SDK
      • c++ windows macos s24 • • Cankar001
      6
      0
      Votes
      6
      Posts
      521
      Views

      C

      Hi @m_adam, following your typescript example it worked now to connect! Thank you very much for your help πŸ™‚

      Merry Christmas and a Happy New Year!

    • C

      Error compiling S24 plugin

      General Talk
      • s24 windows macos c++ • • Cankar001
      4
      0
      Votes
      4
      Posts
      865
      Views

      ferdinandF

      Hey @Cankar001,

      thank you for reaching out to us. It is great to hear that you found your solution! But I have troubles understanding all details of the rest of your question. However:

      PluginStart ist just an alias for the plugin message C4DPL_INIT. A Cinema 4D instance has various stages in its startup and teardown sequence, as expressed by the plugin messages C4DPL_MESSAGES (see also: Plugin Messages). Through out the startup and teardown of Cinema 4D not all systems are available, as binaries/modules are loaded and unloaded and the systems associated with them are being pulled up and torn down. In the end it depends a bit on what you tried to do concretely, but generally speaking, it could very well be that something is not yet "up" when C4DPL_INIT is emitted. But in general, most modules, registries, etc. should be accessible at this point (plugins are loaded after the core and unloaded before the core).

      To get here a more precise answer, I would recommend opening a new topic with concrete code.

      Cheers,
      Ferdinand

    • C

      Rendering debug UI in the viewport via plugin

      Cinema 4D SDK
      • 2024 c++ windows macos • • Cankar001
      8
      0
      Votes
      8
      Posts
      1.3k
      Views

      C

      @ferdinand Thank you very much! I got the min and max distances also working with your input! I used the code example from the docs to traverse through the DeformCache and it worked instantly πŸ™‚