Hey @m_adam thanks alot for the script and advice!
I think this is definitely what puts me off with Python, the limitations of it are quite obvious even to a novice. I guess the challenge is to try to push it as far as you can and almost make a lot of compromises along the way.
Wow amazing, works exactly how I expected! I can also see how this could work in so many instances if you can actually pass a name through to a file which then xpresso is used to pipe through that new name.
I'm going to thoroughly read this to try to understand exactly what's going on, however I've noticed that it brings additional default layer and creates a duplicate of materials...Is there a way to check if materials exist and replace, almost like how alt dragging works when doing it manually?
In my head this is super complex as you would have to also reassign materials after to the newly imported camera...But maybe you know a way that could do this without much complexity?
Thanks for the help really appreciated and it's much easier to learn when it's an idea of your own as you can really break down the method.
Thanks for the fast replies didn't check till I got home!
@blastframe Thanks man will definitely play with that code!
@m_adam Thank you so much...That's definitely correct, just so every time I press the button for script it imports the preset with a different name(based on user input) for camera so that it creates a unique layer without merging into current layers...
I'm going to add the C4D file with xpresso setup...It's alot of simple stuff but it helps when timing animation, it includes textures so you can see what I'm trying to achieve..
As you probably know if I copy and paste the camera to another file it destroys my layer structure so I have to change the camera name in the scene and save it before merging the file...Otherwise it merges layers with the same name...Very long just to create a new camera! It's rendering me unable to use this setup on tight deadlines.
If I could change the camera name on import it would create a unique layer SH_001, SH_002, SH_003 (Up to user) etc and the xpresso setup would stay intact for each camera created...
This is hopefully the start of something I can build on regarding camera scripts, if I can grasp the basic process of generating presets and using python to modify them slightly...
Would be awesome and really appreciate you taking the time to help!
Please let me know if this is too complex to recreate? As long as I know how to create layers assign names from user input etc
I've got a xpresso camera setup that I would love to turn into a simple script if possible.
I just wondered if there's a way to rebuild a document purely through python so once the script is run, it asks the user for a camera name...Then it names everything based on that user input.
Can you build a document containing xpresso purely from Python or are there limitations? I don't even know where to start
Thanks for the reply!
Finally managed to get it working, but only when the user data is placed on the Python tag itself...Which is a little messy to say the least, as you mentioned..
I would prefer to do this as a script but don't know where to start...The Cinema4d Documentation is very overwhelming...
Could you answer these few questions it would really help clear things up for me as I would love to get into plugin development?
Can you create user interfaces with Python or do you somehow build the tool interface with user data? If I wanted this camera rig to be setup via a button would I have to create the xpresso interface or would this be done another way?
Also, is it best to learn Python basics before jumping into C4D plugin development? If so what are the best starting points?
While working in Cinema4d for the past few years I've had so many ideas for workflow plugins that I'd absolutely love to make.
I'm trying to get a user data button to change the parameter of a camera using a Python Generator as I was adviced on C4D cafe that this was the only way...I've managed to get it working by acknowledging the button press and printing to the console but for the life of me I can't get it to change the focal length of the camera...
Here's the code I currently have, it's what I assume would work depending on which button you press..The camera focal length is driven by user data so it's sitting in the Python Generator which is the parent.
Here's the file just a simple camera rig I'm trying to make which has button presets...I know it's simple but I just can't get it to pass on the info and feel so lost in python documentation
And here's the code...
#Welcome to the world of Python
def message(msgId, msgData):
if msgId == c4d.MSG_DESCRIPTION_COMMAND:
if msgData['id'] == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(9)):
op.GetObject()[c4d.ID_USERDATA,8] = 36
elif msgData['id'] == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(13)):
op.GetObject()[c4d.ID_USERDATA,8] = 50
elif msgData['id'] == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(15)):
op.GetObject()[c4d.ID_USERDATA,8] = 300