C4D / RF plugin Python script

Post Reply
dmeyer
Posts: 14
Joined: Fri Jun 25, 2010 2:17 pm

C4D / RF plugin Python script

Post by dmeyer » Tue Nov 16, 2010 3:33 pm

Hello,

I am a part-time pipeline engineer at my company, and trying to write a python script to help out the c4d users.

We run our renderfarm on Qube, which uses the command-line to control Cinema.

Unfortunately with Cinema, when you package a job up to send off to the farm, the paths to realflow mesh files to not get translated into relative paths. Thus, we are trying to write a script to do this. We'd like to have the script change any paths to meshes to a new, specified one. It would be even better if we could get it to happen without opening cinema (as in, modify the c4d file) but lets start with this:

Code: Select all

import c4d
from c4d import documents

 
doc = documents.GetActiveDocument()
 
charAmount = 10 #number of characters to replace at the beginning.
replaceWith = 'Hello'
 
first = doc.GetFirstObject()  
def Browse(obj):  
 	if not obj: return  
 	
 
 	if obj.GetTypeName() == 'RF_MESH_IMPORTER':
 
 		
 	
 		temp = obj[c4d.M_IMP_FILE_PATH]
 
 		result = replaceWith + temp[charAmount:]
 
 		obj[c4d.M_IMP_FILE_PATH] = result
 
 		c4d.DrawViews() #refreshes screen 
    
 	Browse(obj.GetDown())  
 	Browse(obj.GetNext())
Browse(first)
I got the above code from a thread on CGTALK and modified it. When I try to run it nothing happens. Unforunately, while I do have programming experience I have neither a ton of C4D or Python experience.

Any ideas?

We are using R12.

Thanks

Aniki
Posts: 60
Joined: Fri Jun 25, 2010 10:52 am
Contact:

Re: C4D / RF plugin Python script

Post by Aniki » Sat Nov 27, 2010 8:29 pm

Cinema 4Ds RF Plugin works just fine on network, be sure to use the absolute path to some network accessible drive. Tested and works flawlessly..

dmeyer
Posts: 14
Joined: Fri Jun 25, 2010 2:17 pm

Re: C4D / RF plugin Python script

Post by dmeyer » Sat Nov 27, 2010 8:51 pm

Aniki wrote:Cinema 4Ds RF Plugin works just fine on network, be sure to use the absolute path to some network accessible drive. Tested and works flawlessly..
Yes, absolute network paths do work.

What we are trying to avoid is having to change all of the paths to the network share when the artist submits the job.

Aniki
Posts: 60
Joined: Fri Jun 25, 2010 10:52 am
Contact:

Re: C4D / RF plugin Python script

Post by Aniki » Sat Nov 27, 2010 11:14 pm

well, its only the path from the binary loader to the bin files, thats one path to setup once inside the cinema 4d scenes. how much easier could it get ? ;)

even easier if you use xrefs for the binary loaders. so you have all scenes pointing to one xref c4d, if thats your problem.

Post Reply