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

    Update HIERARCHY

    Scheduled Pinned Locked Moved PYTHON Development
    10 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 13/05/2017 at 21:32, xxxxxxxx wrote:

      Hello everyone! When i create a rig there a small problem. When I click on the checkbox, I create an additional element and the entire rig is duplicated. When I turn off the additional element is deleted and again the whole rig is duplicated. At what removal occurs in all duplicates of rig. How to avoid duplicates? Please help me.

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

        On 15/05/2017 at 08:19, xxxxxxxx wrote:

        Hi,

        I really think you will need to provide us with some context and a more elaborate description of your problem.

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

          On 16/05/2017 at 02:06, xxxxxxxx wrote:

          Sorry for  that))) Here some code) Thanks, if you find the error))))

          import os
          import sys

          folder = os.path.dirname(__file__)
          if folder not in sys.path:
              sys.path.insert(0, folder)

          import math
          import c4d
          from c4d import plugins, utils, bitmaps, gui
          from c4d.modules import *
          from classes.ids import *
          from classes.pre import *
          from classes.wiggle import *
          from classes.bable import *

          from classes.controls.resetpsrbox import *
          from classes.controls.controlwiggless import *

          PLUGIN_ID = 1000003

          class Boble(c4d.plugins.ObjectData) :

          def __init__(self) :

          self.SetOptimizeCache(True)

          def Init(self, op) :

          op.SetName("Boble Generator")

          return True

          def GetVirtualObjects(self, op, hierarchyhelp) :
                  doc = c4d.documents.GetActiveDocument()

          dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTYFLAGS_CHILDREN) or op.IsDirty(c4d.DIRTYFLAGS_DATA)
                  if dirty is False:
                       return op.GetCache()

          pre = Pre(op.GetName(), doc.SearchObject(op.GetName()))
                  pre.CreatePre()

          if op[c4d.RM_TRICK] == True:
                      Wiggle_3_1 = Wiggle('five ' + op.GetName(), doc.SearchObject('Rig ' + op.GetName()), 90, 65, doc.SearchObject('Wiggle ' + op.GetName()), doc.SearchObject('Bob ' + op.GetName()))
                      Wiggle_3_1.CreateWiggle()
                      Wiggle_3_2 = Wiggle('six ' + op.GetName(), doc.SearchObject('Rig ' + op.GetName()), -90, 65, doc.SearchObject('Wiggle ' + op.GetName()), doc.SearchObject('Bob ' + op.GetName()))
                      Wiggle_3_2.CreateWiggle()

          elif op[c4d.RM_TRICK] == False:

          self.parent1 = doc.SearchObject('five ' + op.GetName())
                      self.parent2 = doc.SearchObject('six ' + op.GetName())

          self.parent1.Remove()
                      self.parent2.Remove()

          if op[c4d.RM_BABLE] == True:

          br_1_1 = Boble(op.GetName(), 'one')
                      br_1_1.CreateBoble()
                      br_1_2 = Boble(op.GetName(), 'two')
                      br_1_2.CreateBoble()
                      br_2_1 = Boble(op.GetName(), 'tree')
                      br_2_1.CreateBoble()
                      br_2_2 = Boble(op.GetName(), 'four')
                      br_2_2.CreateBoble()

          bableConteiner = Box(op.GetName(),doc.SearchObject(op.GetName()))
                      bableConteiner.CreateBableIn()

          elif op[c4d.RM_BABLE] == False:

          self.bl_1 = doc.SearchObject('babel_1 ' + op.GetName())
                      self.bl_2 = doc.SearchObject('bable_2 ' + op.GetName())
                      self.bl_3 = doc.SearchObject('bable_3 ' + op.GetName())
                      self.bl_4 = doc.SearchObject('bable_4 ' + op.GetName())
                      self.bl_con_1 = doc.SearchObject('connector_1_1 ' + op.GetName())
                      self.bl_con_2 = doc.SearchObject('connector_1_2 ' + op.GetName())
                      self.bl_con_3 = doc.SearchObject('connector_2_1 ' + op.GetName())
                      self.bl_con_4 = doc.SearchObject('connector_2_2 ' + op.GetName())
                      self.findbableContainer = doc.SearchObject('Boble ' + op.GetName())
                      
                      self.bl_1.Remove()
                      self.bl_2.Remove()
                      self.bl_3.Remove()
                      self.bl_4.Remove()
                      self.bl_con_1.Remove()
                      self.bl_con_2.Remove()
                      self.bl_con_3.Remove()
                      self.bl_con_4.Remove()
                      self.findbableContainer.Remove()

          return c4d.BaseObject(c4d.Onull)

          def Draw(self, op, drawpass, bd, bh) :

          doc = c4d.documents.GetActiveDocument()

          if drawpass==c4d.DRAWPASS_HIGHLIGHTS:
                      return c4d.DRAWRESULT_SKIP

          lpPSR = BoxPSR(op.GetName())
                  lpPSR.BoxResetPSR()

          controlWiggles = ControlWiggle(op.GetName())

          if op[c4d.RM_WIGGLE_LOCK] == 1:
                      controlWiggles.ControlWiggleRigLock()
                  else:
                      controlWiggles.ControlWiggleRigUnlock()

          if op[c4d.RM_TRACK] == True:
                      controlWiggles.ControlWiggleRigTwo()
                  else:
                      return False
                  return c4d.DRAWRESULT_OK

          if __name__ == '__main__':

          dir, file = os.path.split(__file__)
              bmp = c4d.bitmaps.BaseBitmap()
              bmp.InitWith(os.path.join(dir, "res", "icon.png"))
              plugins.RegisterObjectPlugin(
                  id = PLUGIN_ID,
                  str = "Boble Generator",
                  g = Boble,
                  description = "Boble Generator",
                  info = c4d.OBJECT_GENERATOR | c4d.OBJECT_HIERARCHYMODIFIER,
                  icon = bmp
              )

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

            On 19/05/2017 at 02:39, xxxxxxxx wrote:

            Hi,

            I don't think anybody in this forum will be able to help you without a detailed problem description and enough detail, how to reproduce the issue. Sorry, if it's me being too stupid to understand the problem, but please bear with me and try to explain it as if to a little child.

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

              On 23/05/2017 at 23:22, xxxxxxxx wrote:

              Same problem https://drive.google.com/open?id=0B6LsRuoqyxhTcF9VZHVJWWlsTkU

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

                On 24/05/2017 at 02:44, xxxxxxxx wrote:

                Hi,

                the video doesn't play here. And I'd really like to suggest you take the time to describe your problem in detail. After all you want other people to invest time in helping you, so it's probably a good idea to make it as easy as possible for them.

                A few notes on your code:

                - You are not allowed to modify the scene (e.g. Remove() objects) within GetVirtualObjects(), see Cinema 4D Threads for details. Such scene changes either belong into a CommandData or at least have to be done in main thread, e.g. in reaction to a button press

                - In GetVirtualObjects() you store object references in member variables. No problem if you use these member variables just like local variables (as you do in the code above), but as soon as you start using them outside the scope of this single function or rely on them to still store correct information upon the next call, I strongly disadvise. It can result in all sorts of troubles. For example what if the referenced object got deleted or replaced by another one (e.g. due to undo action)?

                - You are importing modules and doing quite a bunch of function calls nobody can follow, so it's hard to tell, if anything goes wrong in there

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

                  On 28/05/2017 at 21:42, xxxxxxxx wrote:

                  Yes ! I have such a problem! Can you have examples of how the GetVirtualObjects() and CommandData work?Or is there somewhere on the forum such a discussion?  And thanks for the help)

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

                    On 29/05/2017 at 06:07, xxxxxxxx wrote:

                    Hi,

                    the Python docs download comes with a bunch of examples, see Downloads page[URL-REMOVED] of our blog, here's the archive for R18[URL-REMOVED]. The source of these examples can also be found on GitHub.
                    Examples for CommandData are: Py-MemoryViewer, SculptSaveMask, Py-TextureBaker, Py-CVRss
                    Examples for ObjectData (GetVirtualObjects()) are: Py-Gravitation, SculptModifierDeformer, Py-SpherifyModifier, Py-DoubleCircle, Py-DynamicParametersObject, Py-RoundedTube


                    [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

                      On 30/05/2017 at 00:29, xxxxxxxx wrote:

                      Does anyone have source code SmartStairs 2? I wrote to the developers, but they did not answer me. I wanted to see what's going on inside.)

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

                        On 30/05/2017 at 02:29, xxxxxxxx wrote:

                        Hi,

                        unfortunately MAXON's SDK Team can't do anything about the last question.
                        One reminder, though: Please open a new thread for each unrelated topic. The last question has nothing to do with the original topic of this thread. I hope you don't mind.

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