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
    1. Maxon Developers Forum
    2. Wusiki
    W
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    Wusiki

    @Wusiki

    0
    Reputation
    22
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Wusiki Unfollow Follow

    Latest posts made by Wusiki

    • RE: Get active object after random value

      @m_magalhaes said in Get active object after random value:

      The problem here is that Message() is called before Main() (nothing you can changed)

      Hello.
      Thank you so much. I've understood. Yea, it works. I'd break my mind to understand it by myself. So, then I gonna optimize drawcalls (don't know how to call it another) of LaunchUpdate() func

      posted in Cinema 4D SDK
      W
      Wusiki
    • RE: Get active object after random value

      @m_magalhaes said in Get active object after random value:

      hello,
      Is it possible to have the last version of your file so i have a chance to follow you and try to help you.

      Sure. Thanks in advance. I also commented on my code to better to understand.
      Experieces_old.c4d

      posted in Cinema 4D SDK
      W
      Wusiki
    • RE: Get active object after random value

      I get the same issue. The script gives only previous data (randint limit). I know why, but I don't know how to get an active data.

      def message(id, data):
          if id == c4d.MSG_DESCRIPTION_COMMAND:
              randomButtons = [5] #Random  buttons Ids
              buttonID = data['id']
              SubList = [] #container storing id's values to have to changing
              SubList = randomId_new(SubList,[3,4])#filling the container
              if buttonID[0].id == c4d.ID_USERDATA:#check for user data
                  for RandomButtonId in range (0,len(randomButtons)):#loop for each button
                      if buttonID[1].id == randomButtons[RandomButtonId]:#check button ID
                          for SublistId in range (0,len(SubList[RandomButtonId])):
                              RandomLimit = 0 #limit for randint
                              for id, bc in op.GetUserDataContainer():
                                  if (id == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER,0), c4d.DescLevel(SubList[RandomButtonId][SublistId]))): #check id
                                      cycleBC = bc.GetContainer(c4d.DESC_CYCLE)
                                      for element in cycleBC: #define len of cycleList
                                          RandomLimit += 1
                              op[c4d.ID_USERDATA,SubList[RandomButtonId][SublistId]] = randint(0,RandomLimit - 1) #generate random value
                              print(str(SubList[RandomButtonId][SublistId]) + ': ' + str(RandomLimit)) #checking to console 
      

      You can see what I want via video

      posted in Cinema 4D SDK
      W
      Wusiki
    • RE: Get active object after random value

      @s_bach said in Get active object after random value:

      please use the Q&A system to mark your post as a question.
      Also, please use tags to inform us about which version of Cinema you are using.

      And...Done.

      @s_bach said in Get active object after random value:

      What do you mean with "hierarhy disturbing"? What do you mean with "generate active object after generating random"?

      "Hierarhy disturbing".
      Simply put, there is first func (where there are object details) and there is the second func which generate a random number, but data of active object stores in the first func. Need to execute the second func before first to make it works. But it doesn't right cause' it disturbs actions timeline. Right way is: First display object to the viewport, then generate random nimber after pressing button. But this code requires to run second func before first one.
      "generate active object after generating random"
      I think attached video link better speaks for me.

      @s_bach said in Get active object after random value:

      Why is your user interface on the "Interface" null object and not the Python Tag itself?

      Thanks. Need to try.

      posted in Cinema 4D SDK
      W
      Wusiki
    • Get active object after random value

      Hello everyone.
      There are a few classes.
      One for choosing an object in the CycleList.
      Two for choosing a random object via change c4d.userdata value
      One works fine. But when I choose a random object I need to click on the viewport to update showing object. How to update viewport without clicking?

      I also have tried on the random class:

       c4d.EventAdd()
                  c4d.CallCommand(12147, 12147)
                  c4d.DrawViews( c4d.DA_ONLY_ACTIVE_VIEW|c4d.DA_NO_THREAD|c4d.DA_NO_REDUCTION|c4d.DA_STATICBREAK )
      

      It doesn't work.
      Object class:

       if (config['hideState'] == True): #hide selected object
                  for indexObjectHide in range (0, limit): #loop for geting all objects
                      if (indexObjectHide == self.userdataGroup[c4d.ID_USERDATA,userDataId]): #which object is selected
                          self.parentObject.GetChildren()[indexObjectHide].SetEditorMode(2)
                          self.parentObject.GetChildren()[indexObjectHide].SetRenderMode(2)
                      else:
                          self.parentObject.GetChildren()[indexObjectHide].SetEditorMode(1)
                          self.parentObject.GetChildren()[indexObjectHide].SetRenderMode(1)
      

      Random class:

      if (self.userdataGroup[c4d.ID_USERDATA,userDataId] == True): #If random button clicked
                  SubLists = [] #
                  for ListIndex in range (0,len(config['Random id'])):#config['Random id'] is var where I can point userdata ids ehich will be randomed
                      SubLists.append([config['Random id'][ListIndex]])
                  indexList = []
                  for indexEl in range (0,len(SubLists)): #Loop for each id
                      for id, bc in self.userdataGroup.GetUserDataContainer():
                          cycleBC = bc.GetContainer(c4d.DESC_CYCLE)
                          if (id == c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER,0), c4d.DescLevel(SubLists[indexEl][0]))):
                              for element in cycleBC: # get userdata data
                                  if (len(indexList) == indexEl):
                                      indexList.append([element[0]])
                                  else:
                                      indexList[indexEl].append(element[0])
                      self.userdataGroup[c4d.ID_USERDATA,SubLists[indexEl][0]] = randint(0,len(indexList[indexEl]) - 1) #Change userdata values
                  self.userdataGroup[c4d.ID_USERDATA,userDataId] = False
      

      You can see full code in the attached c4d file. Pls help me
      For better understanding what I want, watch the video:


      Experieces.c4d
      /////
      Seems I've understood why I get the issue. I put random class before object class and it works 'cause in this code, I get an active object before getting random value. But it is doesn't correct in point of view of the code. It's hierarhy disturbing. Ways to generate active object after generating random?

      posted in Cinema 4D SDK python r19
      W
      Wusiki