GetVirtualObjects - do not recreate objects



  • On 24/01/2013 at 06:06, xxxxxxxx wrote:

    with the dirty stuff i just wanted to clarify that your plugins gvo isn't executed on each 
    pass, because i am not so sure that the op is aware of that. i also wanted to stress 
    with my posting that you cannot just store a static part A and insert your non static part
    into the same object A on each call.

    the op seems to be a beginner and there is messing with the actual cache of limits
    imho.



  • On 24/01/2013 at 06:10, xxxxxxxx wrote:

    While still on same topic, where should I put UNDO steps? I tried few versions with no good result - I have to press UNDO twice to get to previous state.

      
        def GetVirtualObjects(self, op, hierarchyhelp) :   
            doc = c4d.documents.GetActiveDocument()   
            doc.StartUndo()   
            myData = op.GetDataInstance()   
            scale = myData.GetReal(RADIUS)   
            baseNull = c4d.BaseObject(c4d.Onull)   
            sphere = c4d.BaseObject(c4d.Osphere)   
            sphere.InsertUnder(baseNull)   
            sphere.SetPhong(True, 1, utils.Rad(80.0))   
      
            doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)   
            sphere[c4d.PRIM_SPHERE_RAD] = scale*100   
      
            doc.EndUndo()   
            print "Virtual END"   
            return baseNull   
    


  • On 24/01/2013 at 06:13, xxxxxxxx wrote:

    You do not need to add undo steps in GetVirtulObjects().



  • On 24/01/2013 at 06:19, xxxxxxxx wrote:

    If I don't, then values snap back to it's default values when I press CMD+Z



  • On 24/01/2013 at 06:45, xxxxxxxx wrote:

    When implementing an ObjectData plugin, you usually do not have to care about undos at all. What
    values snap back to their defaults? The ones of your object in the Attribute Manager?



  • On 24/01/2013 at 07:52, xxxxxxxx wrote:

    Default value for slider and sphere radius is 100.
    I change values with a slider number of times, but when I press CMD+Z, values and sphere radius jumps back to default 100. No matter how many times I change that value - one undo always sets default values. If I press undo second time, I see my object disappears from project.

    But if I do those undos the way I have done now in above code, once I do UNDO - nothing happens, second time - it goes one step back, third time - nothing, fourth - second step back.

    Maybe I am just doing something stupid here in my code, but you can see all my code above.



  • On 24/01/2013 at 07:57, xxxxxxxx wrote:

    Any chance to get a copy of the whole project? If you don't want to make the complete source code
    public, you could send a PM to with a download link and I'll try to catch out the issue.

    -Nik



  • On 24/01/2013 at 08:08, xxxxxxxx wrote:

    funny undo/ gui behaviour can be caused by a corrupted symbolcache. just delete the file and
    restart c4d. the file is located in the prefs folder.



  • On 24/01/2013 at 08:13, xxxxxxxx wrote:

    Niklas, no problem.
    [link removed]
    oh by the way, there are few sliders in GUI, but only one of them is hooked, it's SCALE slider. Just ignore other ones :)

    and thanks for taking a look at it.

    littledevil, that's interesting idea, will check it out. What should I be looking for in prefs folder?



  • On 24/01/2013 at 08:15, xxxxxxxx wrote:

    @Ferdinand: Huh, really? Never experience such an issue. May be due to the fact that I haven't run
    accross the symbolcache-issue often. :)

    Did you mean me with "cpt. capslock"? xD Dunno why the font is so big in my first post, seems to be
    some kind of bug in the chrome browser for android in combination with the rich-text editor...

    Best,
    -Nik



  • On 24/01/2013 at 08:18, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    littledevil, that's interesting idea, will check it out. What should I be looking for in prefs folder?

    well, a file called symbolcache :)



  • On 24/01/2013 at 08:25, xxxxxxxx wrote:

    never heard of symbolcache before:) But there's always a first time:)

    Any ways, I tried on different mac, and still getting save behavior. So my guess is it's not symbolcache related:) There's just some weird bug in my code (maybe) :)



  • On 24/01/2013 at 08:59, xxxxxxxx wrote:

    Hi Tomas,

    first, you can get the document your object is in using op.GetDocument(). It is possible that GVO
    is called, where the object it is called for, is not in the document currently being active (eg. when
    rendering).

    As for your "bug": I just realized it is not a bug. When you change the same attribute multiple
    times without any other action in between, an undo will reset it to the value it started with
    before you began modifieng it. Try it with some other object.

    I never really realized this behavior, maybe because it feels more "natural". This behavior is
    the same in R12 (just checked it), possibly even before this release.

    Best,
    Niklas



  • On 24/01/2013 at 09:09, xxxxxxxx wrote:

    interesting.
    I just noticed that if I have my undos the way I have them right now (see above), INIT function is called twice, but if I don't have StartUndo, AddUndo, EndUndo - then INIT is called only once.

    Does that make any sence?

    However, I am not really sure what you mean with your first statement:) (sorry, dummy here). You say it's better to use op.GetDocument() instead of doc = c4d.documents.GetActiveDocument(), right? I just want to be sure:)

    By the way, R12 and R13 does act the same. I just tested it aswell.



  • On 24/01/2013 at 09:21, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    I just noticed that if I have my undos the way I have them right now (see above), INIT function is called twice, but if I don't have StartUndo, AddUndo, EndUndo - then INIT is called only once.

    This is intended. When you create an undo for your object, Cinema creates a copy of it. And the copy
    must be initialized in some way, too, hm? :)

    Yes, using doc=op.GetDocument() is the correct way, the other is semantically wrong.

    -Niklas



  • On 24/01/2013 at 10:07, xxxxxxxx wrote:

    doc=op.GetDocument()
    

    check:)

    I want to stress undo weirdness once again. I just check hyper mega advanced plugin Py-DoubleCircle. While you move handles in viewport and change radius this way - undo works just fine. BUT is you enter numeric values to Radius in Object tab, then undo don't work (let's say it works but in a weir way)

    So maybe Niklas you ARE right. Maybe that's suppose to be like.

    Any ways, appreciate your input. I learned a lot today. Thank you.


Log in to reply