c4d.GetCommandName() and Expressions

On 27/01/2017 at 13:37, xxxxxxxx wrote:

Hi,

If I use the following code in a Python Script, the object's type (Cube, Sphere, etc) will print to the console:

  
doc = c4d.documents.GetActiveDocument()   
obj = doc.GetActiveObject()   
obj_type = obj.GetType()   
command_name = c4d.GetCommandName(obj_type)   
  
print command_name   

However, if I put the same code in a Python expression - nothing prints.

Is there a reason or workaround for this?
Thank you,

Donovan

On 30/01/2017 at 01:50, xxxxxxxx wrote:

Hi Donovan,

unfortunately it is not yet mentioned in the Python docs, GetCommandName() can only be used from the main thread. By now, it is at least mentioned in the Command Utility Manual, which of course is not the optimal place for a Python developer (yet).

Instead GetObjectName() (which is thread safe) might do the job for you.

On 16/03/2017 at 14:13, xxxxxxxx wrote:

Thanks Andreas!