Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Some attempts at nondestructive modeling

    General Talk
    r21 python
    2
    5
    1.1k
    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.
    • X
      x_nerve
      last edited by x_nerve

      Hi:

      I wrote a Python script that reads the object cache with the Python tag and recreates the cache object to achieve some sense of lossless modeling.But the script is very unstable and prone to program crashes, especially when reading Boolean generators.The script was inspired by the "Py-ParametricTools" plugin for @a_block .link text

      The plug-in was completed in 2017, but when I touched it, I felt I could continue to optimize, so I wrote the script.

      The reason why the script is unstable is that it is difficult to restore the N-Gons face, and many methods have been tried to solve the problem successfully, which also leads to the instability of the program.You can generate animation like a generator, but only for simple objects.Also, this does not apply to effectors because effectors do not cache objects.The following is an example:

      854012250.jpg

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi @x_nerve , thanks for reaching out us.

        Thanks for the remarks but I'm a little bit puzzled by your post and I think I didn't really catch the overall sense of it.
        A few questions that could help me better scope it:

        • is there a reason why you marked the thread as Solved? (by this way looks like you're not looking for support)
        • if you're looking for support:
          • what your plugin is actually trying to do?
          • what is the actual issue you're facing?
          • can you reproduce the issue outside of your plugin with some simple code?

        Looking forward hearing more from you, give best.

        1 Reply Last reply Reply Quote 0
        • X
          x_nerve
          last edited by

          Hi:

          I know there's a function in the Python SDK that detects if the parameters of a subobject have changed, but I want to know if this can be used in Python tags for automatic updates.Python tag updates, which automatically update at the click of an object manager blank, are annoying.Is there a solution?

          1 Reply Last reply Reply Quote 0
          • r_giganteR
            r_gigante
            last edited by

            Hi @x_nerve to get evidence of a sub-object to have changed its parameters' value you can use C4DAtom::GetHDirty() and use the HDIRTYFLAGS::OBJECTbit mask.
            Please be also sure to invoke the above method on the BaseObject returned by BaseTag::GetObject()

            Cheers, R

            1 Reply Last reply Reply Quote 0
            • X
              x_nerve
              last edited by x_nerve

              Hi:

              After a trial run, the script was tested successfully. By setting the name suffix of Python Tag, the problem of repeated running of Tag can be solved.

              Taking c4d.DIRTYFLAGS_SELECT as an example, if the point, line, and surface selections change, it will execute, otherwise it won't.

              The Python script code is as follows:

              import c4d
              #e-mail: [email protected]
              
              def main():
                     
                  Name = op.GetName()
              
                  Objects = op.GetObject()
                  Changed = Objects.GetDirty(c4d.DIRTYFLAGS_SELECT)
              
                  Text = ["xit" + str(Changed)[-1]]
                  
                  if str(Name).count(Text[0][:-1]) != 0 :
                      
                      if str(Name).find(Text[0][:-1]) != str(Name).rfind(Text[0][:-1]) :
                          
                          if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] :
                          
                              if str(Name).find(Text[0][:-1]) <= 0:
                                  
                                  #Do not execute, exit the program.
                                  print ("Does not perform.")
                                  op.SetName(str(Text[0]))
                                  
                                  return
                              
                              else:
                                  #Do not execute, exit the program.
                                  op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0]))
                                  print ("Does not perform.")
                                  
                                  return
                                  
                          else:
                              if str(Name).find(Text[0][:-1]) <= 0:
                                  
                                  op.SetName(str(Text[0]))
                                  print ("Perform.")
                                  
                              else:
                                  
                                  op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0]))
                                  print ("Perform.")
              
                      else:
                          
                          if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] :
                              #Do not execute, exit the program.
                          
                              print ("Does not perform.")
                              return
              
                          else:
              
                              op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0]))
                              print ("Perform.")
              
                  else:
                      print ("Perform.")
                      op.SetName(str(Name) + str(Text[0]))
                  
              
              
                  print ("pass")
                  #The next thing to execute.
              
              
              
              
              1 Reply Last reply Reply Quote 1
              • First post
                Last post