THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/11/2012 at 08:04, xxxxxxxx wrote:
thanks once again for your response.
I know, that my code looks awfull.
My progress in learning python must look rediculous but that happens If you just have 1 Day max per month. never the less I want to realize my ideas. And I do. It takes a while, it looks awfull, it sticks to no conventions. but (as the projects are smal) they work. thats not beautifull but I cant do better (at least for now)
I have no idea of constants already defined by cinema just not jet learned. I still have problems of understanding classes, initialistaion and the rest of this objectbased stuff.
I now use the method, as you said (was it wrong the way I did it (it wasnt object oriented right?))
for the naming conventions... I will have a look at them, thats a good thing.
my execute is just a shortend version (as mentioned) and therefore doesn't make much sense
again sorry for that code (not bad willing, just disabillity) but I wrote it. it took me quite some time, and it works with the exeption of what I explained and that I cant solve. and unfortunately havent seen a answer to it in your post :(
and to disgust you even a bit more here is the whole code :)
import c4d import os import sys from c4d import gui, plugins, bitmaps PLUGIN_ID = 1000010 frame = 0 TIMELINEONOFF = 1001 CAMONOFF = 1000 offset = (0.0,0.0,0.0) zoom = 0,0 class fs_pa(plugins.TagData) : # anfang_ layout inizialisieren def Init(self, node) : tag = node data = tag.GetDataInstance() # set camera dependent priority=c4d.PriorityData() priority.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT,True) node[c4d.EXPRESSION_PRIORITY]=priority # put in values for the user data data.SetBool(TIMELINEONOFF, True) data.SetBool(CAMONOFF, True) return True # Ende_ layout inizialisieren def Execute(self, tag, doc, op, bt, priority, flags) : global frame, offset, zoom data = tag.GetDataInstance() cframe = doc.GetTime().GetFrame(doc.GetFps()) visible = 1 draw = doc.GetActiveBaseDraw() cam = draw.GetSceneCamera(doc) coffset = cam.GetOffset() czoom = cam.GetFocus() print coffset print czoom OnOffTimeline = data.GetBool(TIMELINEONOFF) OnOffCam = data.GetBool(CAMONOFF) # evaluate timeline if OnOffTimeline: if cframe != frame: visible = 0 frame = cframe # evaluate camera if OnOffCam: # movement if coffset != offset: visible = 0 offset = coffset #zoom if czoom != zoom: visible = 0 zoom = czoom # set visibility if visible == 0: op.SetEditorMode(c4d.MODE_OFF) else: op.SetEditorMode(c4d.MODE_UNDEF) # ende hier den code rein return c4d.EXECUTIONRESULT_OK if __name__ == "__main__": bmp = bitmaps.BaseBitmap() dir, file = os.path.split(__file__) bitmapfile = os.path.join(dir, "res", "Icon.tif") #print bitmapfile result = bmp.InitWith(bitmapfile) if not result: print "Error loading bitmap!" okyn = plugins.RegisterTagPlugin(id=PLUGIN_ID, str="FS_preview_acelerator", info=c4d.TAG_VISIBLE|c4d.TAG_EXPRESSION, g=fs_pa, description="fs_pa", icon=bmp) print "fs_preview_accelerator initialized, v01: ", okyn