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
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. Cankar001
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 21
    • Best 2
    • Controversial 0
    • Groups 0

    Cankar001

    @Cankar001

    I am Can, 23 years old and currently working at Corsair as a graphics developer and studying computer science in germany.

    2
    Reputation
    10
    Profile views
    21
    Posts
    0
    Followers
    0
    Following
    Joined Last Online
    Website www.cankarka.com Location DΓΌsseldorf, Germany Age 24

    Cankar001 Unfollow Follow

    Best posts made by Cankar001

    • RE: Rendering debug UI in the viewport via plugin

      @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 πŸ™‚

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: WebSocket usage in 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!

      posted in Cinema 4D SDK
      C
      Cankar001

    Latest posts made by Cankar001

    • RE: Retrieve the current Unit and listen to changes

      Hi @ferdinand,
      thank you very much for your detailed answer! It helped me a lot understanding the unit system better, I have now written 2 functions, that retrieve the current set unit of the document, which are then used to A) display the current unit in the viewport and B) to scale the distances based on the unit scale:

      static maxon::String GetCurrentSelectedUnit(const BaseDocument* document)
      {
      	if (!document)
      		return ""_s;
      
      	const UnitScaleData* unitScale = document->GetDataInstanceRef().GetCustomDataType<UnitScaleData>(DOCUMENT_DOCUNIT);
      	return unitScale->ToUnitString();
      }
      
      static Float GetCurrentUnitScale(const BaseDocument* document)
      {
      	if (!document)
      	{
      		ApplicationOutput("Failed to retrieve the current document.");
      		return 1.0f;
      	}
      
      	const UnitScaleData* unitScale = document->GetDataInstanceRef().GetCustomDataType<UnitScaleData>(DOCUMENT_DOCUNIT);
      	if (unitScale)
      	{
      		Float currentScale = 1.0f;
      		DOCUMENT_UNIT currentUnit = DOCUMENT_UNIT::UNDEFINED;
      		if (!unitScale->GetUnitScale(currentScale, currentUnit))
      		{
      			ApplicationOutput("Failed to retrieve the current unit multiplier.");
      			return 1.0f;
      		}
      
      		if (currentUnit == DOCUMENT_UNIT::UNDEFINED)
      		{
      			ApplicationOutput("Failed to extract the current set unit.");
      			return 1.0f;
      		}
      
      		return currentScale;
      	}
      
      	ApplicationOutput("Failed to retrieve the current unit scale.");
      	return 1.0f;
      }
      

      Those two functions seem to behave as expected now and the text changes, when the project scale is changed and also when changing the scalar value, the distance gets scaled properly. Thank you a lot for the video as well, it helped a lot to see the actual values change live πŸ˜„

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: Retrieve the current Unit and listen to changes

      @m_adam Thanks for your quick reply! I wrote a more detailed mail to the mail address you provided πŸ˜„

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: Retrieve the current Unit and listen to changes

      @m_adam Thanks for the clarification! What I am trying to achieve is that the whole units for the user get changed. When I change the display setting manually, all the units in the UI also change and the values get re-calculated for the selected unit. My high level goal is, that my plugin also should do these re-calculations, once the user changes the unit in the settings, because right now my plugin would show the wrong values, when the unit gets changed from the default unit. So yes I would need to listen to the display unit I think, because the calculations should be done when the user wanted the units to change

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: Retrieve the current Unit and listen to changes

      @m_adam And how exactly would I retrieve and change the unit itself? I tried it this way:

      Bool UnitChangeDetector::CoreMessage(Int32 id, const BaseContainer& bc)
      {
      	if (id == EVMSG_CHANGE)
      	{
      		BaseDocument* doc = GetActiveDocument();
      		if (!doc)
      		{
      			ApplicationOutput("Failed to get active document!");
      			return true;
      		}
      
      		BaseContainer data = doc->GetData(DOCUMENTSETTINGS::GENERAL);
      		data.SetInt32(DOCUMENT_DOCUNIT, (Int32)DOCUMENT_UNIT::KM);
      		doc->SetData(DOCUMENTSETTINGS::GENERAL, data);
      	}
      
      	return true;
      }
      

      (Only for testing of course, the final version would not look like this)

      But when I check the settings in Edit > Program Settings > Units > Display it still says Centimeters instead of the expected kilometers.

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: Retrieve the current Unit and listen to changes

      Hi Maxime, I don't have any UI in my plugin, as the control flow is controlled pureley over a websocket. The plugin calculates some data, when the command is received over the websocket and displays some debug ui in the rendering viewport (basic line rendering), but that's about it so I don't have any plugin setting or UI panel. Is it possible to get notified by a core message about the unit change?

      posted in Cinema 4D SDK
      C
      Cankar001
    • Retrieve the current Unit and listen to changes

      Hello, I need a way to retrieve not only the current unit of the editor and the world matrices, but also to get notified in my plugin, when the user changes the unit in the settings window, because then I will also need to re-calculate the data generated by my plugin to fit the new unit. Is there a way to subscribe to those type of changes, or would I have to write a more complex system to always stay up-to-date with the latest unit settings?
      The default unit of the editor should be centimeters I believe, but most use cases of my plugin would probably be millimeters, or even nanometers sometimes.

      Thanks for any help!

      posted in Cinema 4D SDK c++ s24
      C
      Cankar001
    • RE: Making changes to the document through a websocket

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

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: Making changes to the document through a websocket

      @m_adam Thanks got it! One last unrelated question, how can I switch between world and object coordinates through my plugin? I know that I can switch the tool through

      BaseDocument *doc = GetActiveDocument();
      doc->SetAction(ID_MODELING_MOVE);
      

      But couldn't find any example for the coordinate space, that's the last feature set that I am missing for now πŸ˜„

      posted in Cinema 4D SDK
      C
      Cankar001
    • RE: Making changes to the document through a websocket

      I made some progress now, I changed the message type to be MessageData, to retrieve Core messages and in the websocket layer I now use SpecialEventAdd() with my own event ids, I see that the CoreMessage() method also supports the BaseContainer as a parameter, is it possible to fill it with custom data when calling SpecialEventAdd()? The function only seems to take two Uints as additional parameters, how would I get some custom data into my own CoreMessage method call?

      Thank you again! πŸ™‚

      posted in Cinema 4D SDK
      C
      Cankar001
    • Making changes to the document through a websocket

      Hi, I am currently working on a way, to trigger different actions through a websocket, for example triggering the undo/redo or to create a simple cube, I searched through the documentation a lot, and found the relevant functions, like creating a cube:

      BaseDocument* const document = GetActiveDocument();
      if (document == nullptr)
          return false;
      
      BaseObject* const cubeObject = BaseObject::Alloc(Ocube);
      if (cubeObject == nullptr)
          return false;
      
      cubeObject->SetName("This is a new object"_s);
      document->InsertObject(cubeObject, nullptr, nullptr);
      
      EventAdd();
      

      but I am not quite sure about the context of how to use them. For example I tried making a hidden CommandData plugin to create a simple cube when it is called, to also include the creation in the undo/redo system but if the plugin is hidden from the user, its Execute function obviously is never called. Similarily, I tried calling the

      BaseDocument *doc = GetActiveDocument();
      if (doc)
          doc->DoUndo(); 
      

      from within the websocket OnMessage function directly, this resultet in a breakpoint being hit inside the DoUndo() function. Probably caused by the networking layer being in a different thread than the main thread (I assume) and thus can not modify the BaseDocument in any way.

      How would a design look like, to trigger such actions from within a websocket? Any help would be greatly appreciated!

      posted in Cinema 4D SDK windows s24 c++
      C
      Cankar001