How do I retrieve a command call from it's index number ?
-
For example I get from the Script Log
c4d.CallCommand(14046) # SplitIs there an Index page where I can see to what method that number belongs to ?
-
Hey @Dimitris_Derm. ,
what do you mean by 'method'?
CallCommandjust invokes the CommandData plugin which has been registered under the plugin ID you passed to the call.What you can do, is resolve the numeric plugin ID integer value to a symbol. But unlike for message IDs, the docs currently do not resolve symbols to their integer values. You can do two things:
- Just search in the main symbol definition file with a text editor, i.e.,
{c4d}/resource/modules/python/libs/python311/c4d/__init__.py - Or use mxutils.SymbolTranslationCache which exists for the very purpose of resolving such integer values to symbols.
But in your case,
14046, you will draw a blank in both cases, which simply means developers never defined a public symbol for that command.

Cheers,
Ferdinand - Just search in the main symbol definition file with a text editor, i.e.,
-
@ferdinand
Thank you for replying.By "method" I meant the programmatic term which some times coincides with the term "function".
In my case I was expecting it to return the c4d.MCOMMAND_SPLIT but then remembered it's actually an ID.Isn't using the Script Log a good way to quickly and easy find all the appropriate function/class calls of objects/attributes/tools instead of manually searching the API documentation ?
-
Hey @Dimitris_Derm. ,
I still do not 100% follow what you are saying and asking, which likely means that you or I are misunderstanding something.
What are Commands?
Cinema 4D is built itself on the same plugin architecture offered to third parties. There are many plugin types in Cinema 4D, but a central one is CommandData. A command is an operation that can be invoked without any arguments except the plugin ID of the command to invoke (and optionally a sub ID).
CallComandis the function to call commands by their command/plugin ID. I.e., when you implement a command plugin as a user, everyone can call it via its command ID. Commands in this sense are not to be confused with modelling or uv commands, which are a different thing.Almost all buttons and menu entries in Cinema 4D are commands. So, when you for example implement an
ObjectData'Plane' plugin and register it, Cinema 4D will create a hiddenCommandDataplugin for you, so that this object can be created from a menu. Here shown with the builtin 'Plane' object:
What are Symbols?
The raw integer values for plugin IDs are usually (but not always) aliased with a 'symbol'. Symbol is just programmer slang for an alphanumeric label under which some data is accessible. E.g.,
foo,bar, andbazbelow are symbols:foo: int = 123456 bar: dict[str, float] = {"Hello": 1.0, "World": 2.0} baz: callable = lambda x: x * 2In C(++), the langauge Cinema 4D is written in, the word symbol is very common. In the Cinema API it always refers to some alpha-numeric label for some integer value. There is code which is shipped to customers (the public APIs) and there is code that is internal. In order not to have users use raw integer values, we have to define such symbol, i.e., alias in the public API. This does not always happen.
What is the Script Log doing?
The script log is just a series of the the commands being called. There are no classes, functions, or methods. In some cases the script log creates more complex code (for tools), but the script log is never a place to learn the API, as it only operates via command IDs. And the script log uses the raw integer values because for once there is not always a symbol, and it would also not be trivial to access the symbol for each command from the C++ code that generates the log.

Cheers,
FerdinandPS:
By "method" I meant the programmatic term which some times coincides with the term "function".
I understood that, but just as a clarification, method and function are not synonymous. A method is a function that is associated with an object (i.e., it is a member of a class). A function is a more general term that can refer to any callable piece of code, including methods, but also standalone functions that are not associated with any object.
-
@ferdinand
This was very educational thank you !Call Commands ≠ Modelling Commands
Symbol = Name of Constant value or data structure that is used with an immutable intend
Script Log -> not your API dictionary (I was influenced by a very old post in an old forum probably from Noseman when he mentioned that if in any case someone was interested in finding what function or method call C4D is using for a specific tool/attribute we can see if from the Script Log)One more thing...
I've never seen a Call Command with two IDs. What's the common second one ?
In your screenshot CallCammands have all two IDs. Mine has always one. -
The second ID is the sub ID. You can have a command (FOO = 100) which supports the sub-commands (BAR=1, and BAZ=2). So, you can then call CallCommand(100, 1) or CallCommand(100, 2) to invoke the two different things FOO can do. But as you said yourself, this is a rather unusual thing, and it is even more unusual that I manged to randomly click five things in a row that all have sub IDs

What should also be said is that my little "extrude" log there does not really reproduce the modelling operations I carried out. It just runs the tools in the order they are invoked. And because when you run this right after your created the log, the extrude tool will for example still have set the same extrude depth from the last operation. But when you manually extrude something, and then run the script again, it will use these new current extrude tool settings, i.e., and not the ones from when your 'recorded' the log.
The script log can be useful, but it is not the auto-script-recording feature users often whish it was.