Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi there! Do someone know a way to rename a nullobject in c4d by the filename, so that the name of the null-object changes, if the c4d-file changes? I mean something like the token-system at the renderpath. I never used python before, just a bit of xpresso. That would save me and maybe others a lot of time.
You just need to add a python tag to your object and paste the following code.
Simple as that:
import c4d def main(): if not doc: return doc_name = doc.GetDocumentName() null = op.GetMain() if not null: return null.SetName(doc_name)
Download here: null-docname.c4d
Hope it helps.
Cheers, Lasse
Wow, Thanks a lot!
@lasselauch What if i just want the name without .c4d?
http://letmegooglethat.com/?q=split+extension+from+filename+python
@lasselauch sorry i'm too bad at this. cant fix that. i found this before, but i don't know how to implement it in c4d.
Of course there are a lot of ways to spin this, but I guess in most cases this should be enough:
# import os import c4d def main(): if not doc: return docname = doc.GetDocumentName() # docname, _ = os.path.splitext(docname) docname = docname.replace('.c4d', '') null = op.GetMain() if not null: return null.SetName(docname)
Download: null-docname.c4d
Hi @Jasper-Sek,
thank you for reaching out to us. And thank you @lasselauch for jumping in. The solutions provided by @lasselauch are correct, but one might want to consider that Cinema is also capable of opening non-c4d files (I know, it's crazy ;)). So you should use os.path.splitext(docname).
os.path.splitext(docname)
Cheers, Ferdinand
PS: @lasselauch I know that you meant this in a light-hearted manner, but "let-me-google-that-for-you" can be misconstrued. People have different information needs and things that seem trivial or obvious to you, are not for them. Programming can be a confusing topic and we would like this to be a welcoming place for everyone and subsequently stay away from all "RTFM"-notions.
@zipit said in Rename object by filename:
Yep, definitely meant in a light-hearted manner!!! You're totally right.. that's why I provided the correct answer.
@zipit @lasselauch thank you both for your time and knowledge!