Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    c4d.GetCommandName() and Expressions

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 341 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          Thanks Andreas!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post