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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    CSTO and materials

    Scheduled Pinned Locked Moved PYTHON Development
    9 Posts 0 Posters 1.1k 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 19/12/2017 at 06:00, xxxxxxxx wrote:

      In my CSTO function I use a new document to copy my object to.
      However, when I do so, the materials used are not copied to the new document and thus the result of the CSTO has no material information, displaying a question mark.

      What can i do in order not to loose the material information.

              newDoc = c4d.documents.BaseDocument()
              newDoc.InsertObject(obj)
        
              objList = c4d.utils.SendModelingCommand(
                  command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                  list = [obj],
                  mode = c4d.MODELINGCOMMANDMODE_ALL,
                  doc = newDoc,
                  flags = c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE)
        
              if objList == False:
                  print "error CSTONewDoc."
                          
              obj.Remove() 
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 19/12/2017 at 06:05, xxxxxxxx wrote:

        Use c4d.documents.IsolateObjects

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

          On 19/12/2017 at 07:06, xxxxxxxx wrote:

          So, I use it to copy my object to a new document and using that document i do a csto.

          After that, do I have to copy (how) the resulting object back to my original document?

          The code below gives me still the question marks, indicating that the materials were not found.

                  newDoc = c4d.documents.IsolateObjects(doc, [obj])
                  
                  objList = c4d.utils.SendModelingCommand(
                      command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                      list = [obj],
                      mode = c4d.MODELINGCOMMANDMODE_ALL,
                      doc = newDoc)
                      #flags = c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE)
                  if objList == False:
                      print "error CSTONewDoc."
                              
                  obj.Remove() 
          	return objList[0]
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 20/12/2017 at 05:20, xxxxxxxx wrote:

            Hi Pim,

            Where are you using the posted code? Inside GetVirtualObjects()? What's obj in it?

            If a temporary document is created for CSTO then the command loses track of the materials.
            And IsolateObjects() copies the passed object so you don't know the object that has to be used for CSTO.

            It is recommended to pass a clone of the object to apply CSTO on. So you can pass obj.GetClone().
            The document for CSTO can simply be obj's document - obj.GetDocument().
            CSTO should keep materials with these changes.

            Note SendModelingCommand() flags parameter only accepts either MODELINGCOMMANDFLAGS_0 or MODELINGCOMMANDFLAGS_CREATEUNDO.
            The settings for a modeling command have to be passed to bc parameter.

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

              On 20/12/2017 at 05:49, xxxxxxxx wrote:

              Hi Yannick,

              Yes it is inside GetVirtualObjects() and after GetAndCheckHierarchyClone().

              Obj is a null with a smoothing deformer en a polygon object as child's.
              The polygon object has a texture tag and a weight tag.

              I do not fully understand your sentence
              "It is recommended to pass a clone of the object to apply CSTO on. So you can pass obj.GetClone().
              The document for CSTO can simply be obj's document - obj.GetDocument().
              CSTO should keep materials with these changes."

              - I do not see a difference when using a clone, but I will try again.
              - If I use the current document, obj.GetDocument(), the weight setting in the smoothing deformer is lost.
              If I use a new document, the weight setting in the smoothing deformer is ok.
              But then the material is lost due the new document.

              That is why I want to know how to keep the mat information when using csto and e new document.

              -Pim

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

                On 21/12/2017 at 03:26, xxxxxxxx wrote:

                Hi Pim,

                Ok, I believe you use the code posted in the other thread Vertex map is not correctly filled?

                You can't get both the weight and material shown as expected.
                The vertex map is created on a cache object and is not part of the document, while the material is.

                So the solution is to add the vertex map to the child's polygon object of your generator, instead of creating it virtually.
                Also this way it would give more freedom to define the vertex map, for instance with the Paint Tool.

                And about passing a clone to CSTO, you're right it's not needed.

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

                  On 21/12/2017 at 03:33, xxxxxxxx wrote:

                  Sorry, I do not fully understand.

                  I am adding the vertex weight to the polygon object.
                  Then I copy this weight tag into the Stiffness map field of the Smoothing deformer object.
                  Both are placed under a Null and that null must be CSTOed.

                  Could you give an example?

                  - Pim

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

                    On 21/12/2017 at 08:43, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    Hi Pim,
                    So the solution is to add the vertex map to the child's polygon object of your generator , instead of creating it virtually.

                    I mean the vertex map should be manually added to the generator's child, not virtually to the child's clone inside GetVirtualObjects().
                    Then access the vertex map with GetTag() on the child from GetVirtualObjects().
                    Finally CSTO should be performed with the generator's document, not with a temporary one.

                    This changes the workflow but is there a strong reason to generate the vertex map inside your generator?

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

                      On 21/12/2017 at 09:13, xxxxxxxx wrote:

                      Ok, i see, but yes, the vertex map is generated inside getvirtualobjects().
                      IT is based on csto's Before.
                      The generator can hold numerous children.

                      But if this is the only way, then we must think about the workflow.

                      Thanks, Pim

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