offset XRef animation
-
On 09/04/2013 at 08:55, xxxxxxxx wrote:
Hi all,
I am trying to set the 'offset' parameter of an XRef object, but I can't get it to work. Does anybody know what I am doing wrong?
Here's my code:
op[c4d.ID_CA_XREF_OFFSET] = c4d.BaseTime(10,doc.GetFps())
c4d.EventAdd()Thanks in advance!
-
On 09/04/2013 at 09:16, xxxxxxxx wrote:
your code is technically correct, however the definition of your basetime is a bit unusual.
the basetime denominator is not meant to be the documents frames per second. basetime
is just a format to store fractional values like 1/3 without rounding errors. the basetime in
your example would be for 30 fps 10.0/30.0 = 0.3_ sec. -
On 09/04/2013 at 10:20, xxxxxxxx wrote:
Hi, and thanks for the reply.
So do you know what to change to get it to work? What is the correct use of c4d.basetime?
Grtz!
-
On 09/04/2013 at 10:36, xxxxxxxx wrote:
it is difficult to say what is right and what is wrong in your context. when you want to set
the xref time offset to 10 seconds it is simplyop[c4d.ID_CA_XREF_OFFSET] = c4d.BaseTime(10)
if your code still does not work as expected you will have to add a more extensive example.
-
On 09/04/2013 at 11:31, xxxxxxxx wrote:
Hi again,
If I have an XRef object in the scene, select it and run this code:
import c4d
op[c4d.ID_CA_XREF_OFFSET] = c4d.BaseTime(10)
c4d.EventAdd()Then nothing happens. No changed offset, no errors in the console. Nothing.
-
On 09/04/2013 at 12:09, xxxxxxxx wrote:
i do not mean to be rude but your code does not make any sense at all. op is a predefined
variable which is pointing to the hosting object for a script. for an actual script this is None,
for a python tag it is the tag and for a python node the GvNode. so op can never be a xref
in a scripting environment. also your snippet is pretty unusual, as you include the import
statements but not any wrapping method for your code.this script will set the time offset to 10 sec for the currently selected xref. edit: it does not
actually check if obj is a baselist2d (and a xref) so this is something you might want to change
for an actual scriptimport c4d def main() : obj = doc.GetActiveObject() obj[c4d.ID_CA_XREF_GENERATOR]]= True obj[c4d.ID_CA_XREF_OFFSET] = c4d.BaseTime(10) c4d.EventAdd() if __name__=='__main__': main()
-
On 09/04/2013 at 12:27, xxxxxxxx wrote:
And Hi again
Hmmm... either I am not getting it or something weird is going on, because if I run your code while an XRef object is selected, the offset does not change. (By the way, there is one bracket too many in your script that caused it to throw an error initially) Have you tried the script yourself? Does it work for you?
I modified your code a bit to test some things. When i put in some lines to change some other parameters, those lines seem to work fine. See the comments in the code. Strange...
Thanks very much for taking the time to help me though! Cheers!
import c4d
def main() :
obj = doc.GetActiveObject()
#this doesn't seem to do anything:
obj[c4d.ID_CA_XREF_GENERATOR] = True
obj[c4d.ID_CA_XREF_OFFSET] = c4d.BaseTime(10)
#this, however, works fine:
obj[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X] = 10
obj[c4d.ID_CA_XREF_SHOWOBJECTS] = False
c4d.EventAdd()if __name__=='__main__':
main() -
On 09/04/2013 at 12:52, xxxxxxxx wrote:
hi,
no i hadn't tested it. there is some strange behaviour for xref objects going on. but if you set
the generator flag manually (not sure why c4d refuses it to be set programmatically) the offset
value will be written correctly. this time i have actually tested it -
On 09/04/2013 at 12:55, xxxxxxxx wrote:
Ah! Finally! Thanks a lot man!
-
On 09/04/2013 at 14:54, xxxxxxxx wrote:
op is referring to the active object in a script, so you can omitt this line: obj = doc.GetActiveObject()
Best,
-Niklas