Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Properly update viewport/scene for CSTO [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 371 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 16/02/2015 at 13:56, xxxxxxxx wrote:

      I have a script that does current state to object, that NiklasR showed me some time ago. It works fine, but what I have been finding is that if I wanted to say move a joint and then CSTO that mesh, nothing I do seems to work. If I manually set it and run the script to CSTO it will work. So my question is, what must be done to update the viewport/editor or whatever to make it properly convert in the new pose?

      Some pseudocode:

      joint.SetRelPos(c4d.Vector(100, 0, 0))
      CSTO(obj)

      It makes me a duplicate of the mesh, but not at this new deformed pose even though the CSTO code is using GetDeformCache(). The CSTO function basically gets the deform cache, creates a new polygon object with the same number of points, and does SetAllPoints on this new mesh to be the GetAllPoints from the deformCache, and the same for Polygons.

      I've tried various EventAdd and DrawViews flags but neither seems to properly update upon duplication. Can someone point me in the right direction?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 17/02/2015 at 02:32, xxxxxxxx wrote:

        Hi Bret,

        sometimes GetClone() is needed to make current state operations valid.
        This code should work:

          
          joint4 = doc.SearchObject("Joint.4")  
          mesh = doc.SearchObject("Mesh")  
          
          pos = joint4.GetRelPos()  
          joint4.SetRelPos(pos*2)  
          
          
          virtualop = utils.SendModelingCommand(command=c4d.MCOMMAND_CURRENTSTATETOOBJECT,  
                                                          list=[mesh.GetClone()],  
                                                          doc=doc)  
          doc.InsertObject(virtualop[0])  
          c4d.EventAdd()  
        

        Best wishes
        Martin

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 18/02/2015 at 16:41, xxxxxxxx wrote:

          Hi Bret,

          I'd like to know if Martin's answer is sufficient or if you need more help?

          Joey Gaspe
          SDK Support Engineer

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 04/03/2015 at 07:25, xxxxxxxx wrote:

            Hi,

            I'll close this topic as solved due to inactivity.

            Joey Gaspe
            SDK Support Engineer

            1 Reply Last reply Reply Quote 0
            • First post
              Last post