CGTalk > Software > Maxon Cinema 4D
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-08-2013, 03:26 AM   #1
RafikiRob
New Member
portfolio
Robert Reiser
Digimagi Creative Imaging
Greensboro, United States Minor Outlying Islands
 
Join Date: May 2011
Posts: 12
I'm in over my head... please help with a simple script

I know absolutely nothing about scripting. I would love to learn, but my need is too urgent to acquire the knowledge at present. I'm trying to write (what seems to me to be) a simple script, but the 'out of the box' recording feature (script log) doesn't seem to be doing everything that I need.

I basically want to Save, Render Image, Save Image (to the document folder, with a specific name), Close Render Window, Delete two specific objects (by name), Select a specific object (by name), Render, Save Image (to the document folder, with a specific name), Close Project (without Saving).

This is all to render one image that looks right, and another that creates an Alpha channel (mask) for the main object. I have to delete a sky sphere and sweep object and select the main object to get the Alpha to Render correctly on the 2nd image. I have to do this on a hundred or more files, so automation would be great, the problem is, I'm expected to begin delivering these images tomorrow.

Anyway, the following is what I get in the Script Log:

import c4d
from c4d import documents, plugins
#Welcome to the world of Python

def main():
c4d.CallCommand(12098) # Save
c4d.CallCommand(12099) # Render to Picture Viewer
c4d.CallCommand(465001707) # Save as...
c4d.CallCommand(100004787) # Delete
c4d.CallCommand(12099) # Render to Picture Viewer
c4d.CallCommand(465001707) # Save as...
c4d.CallCommand(12664) # Close

if __name__=='__main__':
main()

---

... as you can see, there are no save options (path/name), and no Close Render Window gets recorded. Any help would be greatly appreciated.

Thanks,
Rob
__________________
"He doesn't understand. Explain as you would a child."
- Sarris, Galaxy Quest
 
Old 10-08-2013, 07:36 AM   #2
littledevil
Meh
 
littledevil's Avatar
portfolio
Ferdinand
Germany
 
Join Date: Aug 2002
Posts: 616
1. Saving a c4d file - c4d.documents.SaveDocument(doc, name, saveflags, format). Look into the python docs for more info.

Code:
path = r'\\net01\some\fancy\path\scene01.c4d' # the raw path # save the active document and print something if successful if documents.SaveDocument(doc, path, c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT): print 'Saved file to ', path


2. Closing windows. It is not possible from within the c4d sdk to close windows as this is
an os related process. There might be some pythonic way, but things will get complicated,
as you do not just want to kill a process (os.kill()), but close some sort of MDI window.
I am not sure if the render window has its own process.

3. Selecting stuff to the document. Goes all down in BaseDocument. In scripts the
currently active document is predefined as doc. Check the sdk on the BaseDocument
class for more details. FYI - Selecting objects by their name string is generally a bad
idea.

Code:
someObj = doc.SearchObject('someObj') # search for objects with their name string anotherObj= doc.SearchObject('anotherObj') someObj.Remove() # removes the object node from the document doc.SetActiveObject(anotherObj) # set selection to anotherObj
__________________
There are holes in the sky. Where the rain gets in.
But they're ever so small. That's why the rain is thin.

Last edited by littledevil : 10-08-2013 at 07:41 AM.
 
Old 10-08-2013, 12:33 PM   #3
RafikiRob
New Member
portfolio
Robert Reiser
Digimagi Creative Imaging
Greensboro, United States Minor Outlying Islands
 
Join Date: May 2011
Posts: 12
Thank you littledevil for your reply. I'm sure that, if I had the time to figure it out, it would be very helpful : ) The fact is, there are elements/concepts in it that I don't understand and just don't have time to figure out at present. I was rather hoping for a complete string of code (from start to finish) where I just plug in my variables. I realize that this is a lot to ask for, and my previous experience had told me not to ask for such hands-off (on my part) help. Few people, that is, like to help those who want things completely done for them. People are far more willing to help others learn.

Anyway, I appreciate your time and willingness to help me as you did. I'm definitely going to look into this when time allows.

Rob
__________________
"He doesn't understand. Explain as you would a child."
- Sarris, Galaxy Quest
 
Old 10-08-2013, 02:58 PM   #4
kvb
Now with Less Gout!
 
kvb's Avatar
Kevin V. Barnum
Graphic Designer/3D Artist
Colorvision International
Orlando, USA
 
Join Date: Jan 2007
Posts: 813
Sounds to me like you just need to make use of object buffers. No scripting needed.

-kvb
__________________
www.kvbarnum.com
LOBODESTROYO!!!
 
Old 10-08-2013, 02:58 PM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:33 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.