List of all Cinema 4D IDs?
-
Hello,
I've been trying to find a more up-to-date version of this list of Cinema 4D IDs posted to GitHub by seeminglee. Here is another that was created for COFFEE by Niklas Rosenstein.I find it extremely useful in understanding C4D messages. Does anyone know how I could find/create something like this for R21? Thank you!
-
Hi,
I am not quite sure, if I do understand your question correctly. At least the first link is a dummy module listing members of all types of the c4d module, but you talk about ids and messages. Anyways, you can in both cases just inspect the c4d module. Here is a little function that inverts the
c4d
module dictionary so that you can plug integer symbols into the returned dict and get a list of strings which are associated with that integer (Cinema's symbol namespace is anything but collision free).def _get_smybol_table(): """Function to extract and invert the integer symbols and their corresponding strings symbols from the c4d module. Will ignore all members of ``c4d`` that are not of type ``int`` and members where the string symbol is not all in capitals letters. Returns: dict: The inverted c4d module dict, with integer symbols as keys and string symbols as lists of values. """ tbl = {} for name, sid in c4d.__dict__.items(): if (not isinstance(sid, int) or not isinstance(name, str) or not name.isupper()): continue tbl[sid] = [name] if sid not in tbl else tbl[sid] + [name] return tbl # The symbol table. _SYMBOL_TABLE = _get_smybol_table()
Cheers,
zipit -
Thank you @zipit .
for name, sid in c4d.__dict__.items():
was what I needed! -
Hi @blastframe, while the code provided by @zipit will work for most of the symbols
There will be some symbols missing, some are not uppercase (like Ocube), some are made from other types, likec4d.ID_USERDATA
which return a DescID).So the safest way to process is to retrieve everything that is not a module, a class, a type object, a method or a function.
import c4d import types def GetAllSymbols(): def IsSymbol(x): isSymbols = False obj = getattr(c4d, x) return not isinstance(obj, (types.FunctionType, types.BuiltinFunctionType, types.BuiltinMethodType, types.MethodType, types.UnboundMethodType, types.ClassType, types.TypeType, types.ModuleType)) dirC4D = filter(lambda objStr: IsSymbol(objStr), dir(c4d)) values = {"c4d.{0}".format(objStr): getattr(c4d, objStr) for objStr in dirC4D} return values def main(): allSymbol = GetAllSymbols() for symbol, value in allSymbol.items(): print symbol, value # Execute main() if __name__=='__main__': main()
Cheers,
Maxime. -
@m_adam Thank you for the clarification and the code example, Maxime!