![cinema 4d user data cinema 4d user data](https://www.iamag.co/wp-content/uploads/2018/10/Animated-Plastic-Cover-4.jpg)
Though, Sebastian is right, doing this as a command script seems more logical, since you could assign this to an icon and put that icon anywhere in the GUI, making it scene-independent.Īlso, your name determination code has some issues.įirst, you start the code with two SearchObject()s before you even check for the button. In the link above from the other post, you will find a concept to receive the parent object's messages too I'm not going to repeat it here. Now the main() function is empty (this is the "Execute" method of a tag in this case), and the responder returns early, which means it will only use as much calculation time as needed.įor the code above, the button needs to be in the UserData of the tag! Otherwise, the tag may not receive the message properly. Pass # not needed because no execution is necessary (In more complicated examples that need to react to many different messages, the responder code would probably be a separate method again, but since you only listen for a single message, you can insert it right there.) If all of this identifies the proper message that you want to respond to, you insert your responder code. There, you check for the right type of message, the button type, and finally the id of this button. You need to have a method "message", which receives all the messages sent to objects. However, if you want that button, here's what a message responder does. Oh, and you don't want to put all that into main() but create a message responder, see here: You can change the algorithm to do that, though.) if you have name.1, name.2, name.4 then the next generated name would be name.5 although name.3 is not used yet. (Gaps in the current numbering wouldn't be considered, e.g. This way, you wouldn't need to store the suffix number anywhere because it is determined dynamically, and you automatically use a new number. Create the new object with this number (which is then 1 higher than any previously used number) Find the maximum of these suffix numbers Go through the objects to check (whether they are in a certain list or anywhere in the scene) Global variables (for the counter) are discouraged, so you would need to store the counter in the tag's BaseContainer instead of in the code.īut in general, if you are checking "whether the name exists", the more practical method would be this: