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
    • Register
    • Login

    Doc Merge without Editor Camera change?

    Scheduled Pinned Locked Moved SDK Help
    13 Posts 0 Posters 926 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 05/02/2005 at 09:36, xxxxxxxx wrote:

      Hmm, I cannot confirm that this happens. My plugin Crowdimporter does merge hundreds of objects into the currently active doc and I haven´t encountered the behavior you are describing.

      Are you really just doing sth like this:

      BaseObject* obj = op->GetClone(NULL,alias);
      doc->InsertObject(obj,NULL,NULL,FALSE);
      EventAdd();

      Can you post some code snippets?

      Katachi

      P.s.: If this really happens, why don´t you get the camera beforehand, clone it and copy it back to the docs cam after the whole procedure?

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 05/02/2005 at 10:39, xxxxxxxx wrote:

        Here's the code snippet:

          
             // - Merge loaded Scene with Active Document  
             if (merge && mergeDocument)  
             {  
                  AutoAlloc<AliasTrans> trans;  
                  if (!trans) throw ErrorException(ERROR_MEMORY, "iPDialog.LoadScene.trans");  
                  if (!trans->Init(baseDocument)) throw ErrorException(ERROR_GENERAL, GeLoadString(ERROR_ALIASTRANS_TEXT));  
          
                  BaseMaterial *material, *cmat;  
                  mergeDocument->StartUndo();  
                  for (material = baseDocument->GetFirstMaterial(); material; material = material->GetNext())  
                  {  
                       cmat = (BaseMaterial* )material->GetClone(0, trans);  
                       mergeDocument->InsertMaterial(cmat, NULL, TRUE);  
                       mergeDocument->AddUndo(UNDO_NEW, cmat);  
                  }  
                  mergeDocument->EndUndo();  
          
                  mergeDocument->StartUndo();  
                  group = (BaseObject * )(baseDocument->GetFirstObject()->GetClone(0, trans));  
                  mergeDocument->InsertObject(group, NULL, NULL, TRUE);  
                  mergeDocument->AddUndo(UNDO_NEW, group);  
                  mergeDocument->EndUndo();  
          
                  trans->Translate(TRUE);  
                  KillDocument(baseDocument);  
             }  
          
             EventAdd(EVENT_FORCEREDRAW);  
        

        I have realized that it could be that last statement (EventAdd()) which is causing this, but have not checked yet.

        Where would I find the Editor camera?

        Thanks,

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 05/02/2005 at 10:52, xxxxxxxx wrote:

          Hmm, seems to be nothing that could cause this.
          The editor cam can be gotten through the active BaseDraw, with GetEditorCamera().

          But what do you need a forceredraw for? Simply call EventAdd(), it should do it easily.

          Furthermore, to maybe save performance (or at least to reduce unnecessary code :), only call StartUndo and EndUndo once (at the beginning and in the end).

          Really strange the editor cam is anyhow modified. Are you sure this happens? Did you encounter it on your machine? Or is it maybe only a drawing error when you force the redraw?

          Katachi

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 05/02/2005 at 11:17, xxxxxxxx wrote:

            I forget at this stage, but it was need for something - maybe to get materials updated properly either in the display or material manager.

            Oh no, I want the added object to be an undo step and the changed materials to be another. One thing that I learned about C4D undo is that one undo step is encapsulated between StartUndo() and EndUndo(). So, in effect, the user can remove the material changes and then the added objects separately.

            Yes, this happens and I've seen it happen. I have a user who doesn't like that it happens, so it definitely happens. 🙂

            I'll try the FORCEREDRAW first and then backing/restoring the Editor Camera if that does not work.

            Robert

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 05/02/2005 at 11:22, xxxxxxxx wrote:

              Ah I see. ok, let us know when you find the solution. 🙂

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 05/02/2005 at 11:35, xxxxxxxx wrote:

                Well, removing the EVENT_FORCEREDRAW had no effect.

                It also affects the active camera. Does GetSceneCamera() return the active camera? Otherwise I have no idea which one is.

                Thanks,

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 05/02/2005 at 11:42, xxxxxxxx wrote:

                  yes it will return the active camera IF there is a scene camera. Otherwise you´ll need to use the editor camera.

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 05/02/2005 at 11:45, xxxxxxxx wrote:

                    Right, that's what I figured.

                    Still changing the camera though. Maybe I need to Set...() the camera values after calling EventAdd()?

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 09/02/2005 at 13:41, xxxxxxxx wrote:

                      Sorry that I forgot to get back here.

                      Found the problem: LoadFile() and LoadDocument(). LoadFile() automatically adds the document into the list. This, for some reason, causes the camera change when 'merging' (i.e.: using AliasTrans to clone the objects and materials into the host document). LoadDocument(), since it doesn't insert the document, doesn't cause the camera change. Very odd, but, hey, it works. 🙂

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 10/02/2005 at 09:49, xxxxxxxx wrote:

                        Ah, ok. Thanks for letting us know.

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