How to access userdata via CoffeeScript in Cinema 4D?

How to access userdata via C.O.F.F.E.E. script in Xpresso?


This post has already been read 2805 times!

In this quick example you will learn how to access Userdata via C.O.F.F.E.E. script in Cinema 4D Xpresso.

You may control userdata via xpresso by using #ID_USERDATA command.
Here is an example for assigning a string “Test” to Userdata ID 1. For example that might be used for your copyright notice. You may add protection to your xpresso as well so it cannot be changed without a password. (Click here for adding password protection to Cinema 4D Xpresso tutorial.)

main() { var doc = GetActiveDocument(); var userdata = doc->FindObject("User Data"); // A Null that's holding the User Data userdata#ID_USERDATA:1 = "Test"; } 

Remember all userdatas have unique ID numbers. When you add or remove your userdata
they might still remain in memory and they get +1 ID number. So if you have a complex setup with
lots of userdata options it would be much easier to check their IDs before accessing them.
You can also use If/Else statements to control your setup via userdata.

  1. Nettie

    AFAICT you’ve coerevd all the bases with this answer!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.