How to access userdata via CoffeeScript in Cinema 4D?

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

1

This post has already been read 1426 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"; } 

exampleuserdata
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 Comment

  1. Nettie
    Nettie07-04-2016

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

Leave a Reply