Solved Migrating from the Classic API

Hello again,
It's been a while 😉

I am currently still using the classic API for all plugins, and was looking into creating small "learning" plugins using the new API. Wanted to do so with baby steps, so I thought first to use the classic API for the main framework of the plugin (using PluginStart and the regular registration methods) while using some functionality of the MAXON API.
Not sure if this is even possible, using a mix of classic and new API.

For a first "learning" plugin I though to keep it simple and implement a plugin that has no interaction, but simply displays some information (in the console) when Cinema4D starts.
So, I thought of displaying the MAC address.

From the legacy forum I found a way to do so using the classic API
https://plugincafe.maxon.net/topic/10754/14198_how-to-get-the-ethernet-id-list-solved

And since GetMacAddress doesn't seem to be available in classic API of R20, that's a good opportunity for a learning experience. Well, there seems to be a Machine class which contains GetMacAddress, but haven't found a way how to use that.
And since the purpose was to use the MAXON API I looked further and found NetworkAdapterInterface.
Went looking for information on interfaces, implementation and usage, but examples on GitHub weren't useful. I just cannot wrap my head around it.

The cinemasdk has examples for tool plugins, object, shader, ... These all are resources to learn from. Aren't there any full plugin examples using the new MAXON API? Or have I been looking at the wrong place?

To be honest, first steps into the new API were quite frustratingly overwhelmed.

Hi Daniel, thanks for reaching us and for keeping touching the MAXON API.

First thing first: we do appreciate every single comment spent on this topic, even critical comments like yours, because in the end it means that the community is approaching to it and this is, any case, good!

Getting back to your question, considering that MAXON API is indeed young (yet powerful), it indeed should be used in conjuction with classic API in order to keep delivering plugins until the MAXON API will replace completely the old one.

With regard to your second point I do confirm that although NetwordAdapterInterface is just an interface which could be implemented by 3rd party developers for customized implementations, I'd like to point you to NetworkIpInterface which is a static interface to access network functionality.

In addition to this notes I also would like to point you to the Initialization section in our documentation where the MAXON_INITIALIZATION is explained in all its glory and which, in this case where only MAXON API calls are used, can be handy.

Finally below the code I used to achieve the desired functionality

static maxon::Result<void> InitGlobalString()
{
	iferr_scope;
	
	// get all the adapters on the machine
	maxon::BaseArray<maxon::NetworkAdapter> allNets = maxon::NetworkIpInterface::GetAllNetworkAdapters() iferr_return;
	
	// browse all of them and print the MAC-address
	for (const maxon::NetworkAdapter& adapter : allNets)
	{
		maxon::BaseArray<UChar> macadr = adapter.GetMacAddress() iferr_return;
		ApplicationOutput("Adapter [@]: @", adapter.GetName(), maxon::NetworkIpInterface::MacAddressToString(macadr));
	}
	
	return maxon::OK;
}
// called on system end
static void ClearGlobalString()
{
	// do nothing
}
MAXON_INITIALIZATION(InitGlobalString, ClearGlobalString);

Last but not least, whislt I recommend you to have a look at the microsdk example which represent the simpler yet fully working example of the MAXON API in use, I confirm that more examples are in the work and will for sure be part of a future SDK revision.

Best, Riccardo

Thanks Riccardo,
It all (well, some of it) starts to make sense after your explanation. A big step forward in starting to understand how to proceed with the MAXON API.