Meshsequence Exporter

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/06/2011 at 01:03, xxxxxxxx wrote:

I want to export a meshsequence of an animation. If I set the documenttime to a specific frame e.g. frame 5 and export the document, then cinema always export the mesh of frame 0.

Here ars some code snippets:

minFrame = 0
maxFrame = 10
while minFrame <= maxFrame :
  doc.SetTime(c4d.BaseTime(minFrame, fps))

filepathSuffix = filepath + "_" + str(minFrame) + "." + suffix
  c4d.documents.SaveDocument(doc, filepathSuffix, c4d.SAVEDOCUMENTFLAGS_0, format)

minFrame = minFrame + 1

How can I export the mesh of the frame, the playhead is?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/06/2011 at 06:18, xxxxxxxx wrote:

In that code you set the time to frame 0, so it's starting there.
Set it to start at current frame and set a useful last frame as well,
like doc maxtime or loop maxtime.

Cheers
Lennart

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/06/2011 at 06:58, xxxxxxxx wrote:

In the while-loop I increment the variable "minFrame".

If I set the minTime and maxTime of the document, cinema exports in every loopcycle the mesh of frame 0

Here is my code:

while minFrame <= maxFrame :;
  doc.SetMinTime(c4d.BaseTime(minFrame, fps))
  doc.SetMaxTime(c4d.BaseTime(minFrame + 1, fps))
  doc.SetTime(c4d.BaseTime(minFrame, fps))

filepathSuffix = filepath + "_" + str(minFrame) + "." + suffix
  c4d.documents.SaveDocument(doc, filepathSuffix, c4d.SAVEDOCUMENTFLAGS_0, format)

minFrame = minFrame + 1

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/06/2011 at 07:22, xxxxxxxx wrote:

In Py docs look for "Document Caching" , last in c4d.documents.BaseDocument section.
There's a set up for running the scene, just add your save part in it.

Cheers
Lennart

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/06/2011 at 01:41, xxxxxxxx wrote:

Hi Lennard,

thank you for youre post.

I insert the GeSyncMessage methode to my code, but it has no impact on the results. Cinema exports the mesh of frame 0 to all of the exported files.

Here is the code:

fps = float(doc.GetFps())

minTime = doc.GetMinTime()
  minFrame = int(minTime.Get() * fps)

maxTime = doc.GetMaxTime()
  maxFrame = int(maxTime.Get() * fps)

doc.SetTime(minTime)

while minFrame <= maxFrame :
      c4d.StatusSetBar(100 / maxFrame * minFrame)
      doc.SetTime(c4d.BaseTime(minFrame, fps))
      c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)

filepathSuffix = filepath + "_" + str(minFrame) + "." + suffix
      c4d.documents.SaveDocument(doc, filepathSuffix, c4d.SAVEDOCUMENTFLAGS_0, format)

minFrame = minFrame + 1
 
  c4d.StatusClear()
  c4d.EventAdd(c4d.EVENT_ANIMATE)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/06/2011 at 08:18, xxxxxxxx wrote:

Marcel, do look at the "Document Cache" example closer and
you'll see that you need the DrawViews for anything to happen.

I do recommend using it as is as it works as expected.
Add your save part in it where stated and you're all set.

Cheers
Lennart

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 27/06/2011 at 08:50, xxxxxxxx wrote:

You can see the parts put into it here,
saving the selected object to a c4d file series.
Look up the different functions in Py docs to see what they do.
The .zfill() function is from http://docs.python.org

Cheers
Lennart

  
# Save Selected Object To FileSeries   
  
import c4d   
from c4d import documents, storage   
  
  
def BrowseDoc(doc,tofile) :   
    """ Pass the document you want to run the time through"""   
  
    ctime = doc.GetTime() #save current time   
  
    fps = doc.GetFps()   
    start = doc.GetMinTime().GetFrame(fps) #set min time   
    until = doc.GetMaxTime().GetFrame(fps)   
  
    for f in xrange(start, until) :   
        c4d.StatusSetBar(100*(f-start)/(until-start))   
        doc.SetTime(c4d.BaseTime(f, fps))   
        c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW|c4d.DRAWFLAGS_NO_THREAD|c4d.DRAWFLAGS_NO_REDUCTION|c4d.DRAWFLAGS_STATICBREAK)   
  
        # do your caching here. 'f' is the current frame   
        objdoc = documents.IsolateObjects(doc,[doc.GetActiveObject()])   
        tofile = tofile+'_'+str(f).zfill(5)+'.c4d'   
        c4d.documents.SaveDocument(objdoc,tofile,c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST,c4d.FORMAT_C4DEXPORT)   
  
  
        c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) #update timeline   
  
  
    doc.SetTime(ctime) #set time back   
    c4d.EventAdd(c4d.EVENT_ANIMATE)   
    c4d.StatusClear()   
  
def main() :   
    if doc.GetActiveObject() is None:# Single Object not selected   
        return False   
    tofile = c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING)   
    if tofile:   
        BrowseDoc(doc,tofile)   
  
  
if __name__=='__main__':   
    main()   

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/06/2011 at 00:28, xxxxxxxx wrote:

Hi Lennart,

it works. Thank you so much.