On 28/10/2014 at 15:50, xxxxxxxx wrote:
Hi
The plugin I'm working on generates new, random geometry every frame in the scene - it works perfectly when I scrub through the timeline. But when I go to render some frames, it's stuck on the first frame, obviously not updating / refreshing / communicating with the plugin. Apologies for being a noob - the stripped down code is below - I've commented where my main 'update' code is.
> import c4d
>
> from c4d import gui, plugins, bitmaps
>
> import time, sys, os, subprocess
>
> import logging, logging.handlers
>
> import math, random
>
> from c4d.utils.noise import C4DNoise
>
> from c4d.utils import SinCos
>
> import c4d.utils
>
>
>
>
>
>
>
> __plugin_id__ = 1000002
>
> __version__ = "1.0"
>
> __plugin_title__ = "Vectorfield"
>
>
>
>
> DUMMY = 1000
>
> BTN_ABOUT = 1001
>
>
>
>
> global lastFrame
>
> doc = c4d.documents.GetActiveDocument()
>
> cF = doc.GetTime().GetFrame(doc.GetFps())
>
> lastFrame = cF
>
>
>
>
> # String shown in status bar
>
> HELP_TEXT = "Vectorfield"
>
>
>
>
> class MainDialog(gui.GeDialog) :
>
>
>
>
> def updateScene(self) :
>
>
>
> """
>
>
>
>
> MY CODE GENERATING NEW GEOMETRY EVERY FRAME HERE
>
>
>
>
> """
>
>
>
>
> return True
>
>
>
>
>
>
>
> def InitValues(self) :
>
>
>
>
> return True
>
>
>
>
> def CreateLayout(self) :
>
>
>
>
>
>
>
> self.SetTitle(__plugin_title__)
>
>
>
>
> # Create the menu
>
> self.MenuFlushAll()
>
>
>
>
> # About/Help menu
>
> self.MenuSubBegin("Vectorfield")
>
> self.MenuAddString(BTN_ABOUT, "About")
>
> #self.MenuAddSeparator()
>
> self.MenuSubEnd()
>
>
>
>
> self.MenuFinished()
>
>
>
>
> return True
>
>
>
>
> def about_C4DPluginTemplate(self) :
>
>
>
>
> gui.MessageDialog("{0}\nblah blah\nblah blah\n\nblah blah\n".format(__plugin_title__), c4d.GEMB_OK)
>
>
>
>
> def Message(self, msg, result) :
>
>
>
>
> self.updateScene()
>
>
>
>
> return c4d.gui.GeDialog.Message(self, msg, result)
>
>
>
>
> def CoreMessage(self, id, msg) :
>
>
>
>
> return c4d.gui.GeDialog.CoreMessage(self, id, msg)
>
>
>
>
> def Command(self, id, msg) :
>
>
>
>
>
>
>
> if id == BTN_ABOUT:
>
> self.about_C4DPluginTemplate()
>
>
>
>
> return True
>
>
>
>
>
>
>
>
>
>
> class Vectorfield(plugins.CommandData) :
>
>
>
>
> dialog = None
>
>
>
>
> def Execute(self,doc) :
>
> if self.dialog is None:
>
> self.dialog = MainDialog()
>
>
>
>
> return self.dialog.Open(dlgtype = c4d.DLG_TYPE_ASYNC,
>
> pluginid = __plugin_id__,
>
> defaultw = 300,
>
> defaulth = 400)
>
>
>
>
> def RestoreLayout(self, sec_ref) :
>
> if self.dialog is None:
>
> self.dialog = MainDialog()
>
>
>
>
> return self.dialog.Restore(pluginid = __plugin_id__, secret = sec_ref)
>
>
>
>
>
>
>
>
>
>
> if __name__ == "__main__":
>
>
>
>
> icon = bitmaps.BaseBitmap()
>
> dir, file = os.path.split(__file__)
>
> iconPath = os.path.join(dir, "res", "icon.tif")
>
> icon.InitWith(iconPath)
>
>
>
>
> plugins.RegisterCommandPlugin(id = __plugin_id__,
>
> str = __plugin_title__,
>
> info = 0,
>
> help = HELP_TEXT,
>
> dat = Vectorfield(),
>
> icon = icon)