Navigation

    • Register
    • Login
    • Search
    • Categories
    1. Home
    2. AndreAnjos
    A
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    AndreAnjos

    @AndreAnjos

    1
    Reputation
    80
    Posts
    231
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    AndreAnjos Follow

    Posts made by AndreAnjos

    • RE: ShowPopupDialog Freezes Cinema R21

      @ferdinand
      I just found what perhaps is the issue...

      The world-container. It seems that it runs without freezing if the data is not saved and load from the world container.
      Quiet odd, but perhaps as you said, it corrupted it somehow?

      Just need to find a way to storing data outside of the document.

      Thank you!

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: ShowPopupDialog Freezes Cinema R21

      @ferdinand
      Hi Ferdinand,

      Many thanks for your valid points and I appreciate what you are saying :).

      I've made the changes to use a GeDialog instead for the menu and it works.

      Here's are my results, based on your proposals:

      1. Nope, same issue still.
      2. Not tried it, but may have to give it a go just in case.
      3. Yes done this at the start and simplify the code, all code works until I introduce the ShowPopupDialog(), as any code after this does not run. Then again it may be something associated with it.
      4. Yes, the GetTimer() function is not doing anything, so definitely good idea.
      5. Yes, that was one of the ways I was debugging and again runs anything that I add to it, except ShowPopupDialog().
      6. I'm going to give it another go.

      The undo-block is for something I wrote in between, but for simplification removed it to pinpoint the culprit. :)

      The world-container is definitely a good point. I'm not sure if I should be using it to store data. I think the reasoning behind it was to keep data accessible between loading and unloading of documents, which is mainly what this plugin is doing.
      Would you recommend perhaps a different container to store the data?

      What I found most weird is that works perfectly fine with R19, so perhaps as you pointed out on 2, Cinema needs reinstalling.

      It's all learning and I think I know a bit more about it now and even if I cannot find the solution for this, I already have another way of dealing with it. Not elegant, but works with no issues :).

      Thank you very much for your help and time!

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: ShowPopupDialog Freezes Cinema R21

      @ferdinand
      Hi Ferdinand,

      Thank you for your tips!

      Unfortunately removing the other plugins does not make a difference, from what I can understand.

      I've also run the general popup dialog and it works fine with no freezing.

      Not sure what to do about this except perhaps change the c4d.gui.ShowPopupDialog to a c4d.gui.GeDialog
      and create a simple menu. Any thoughts?

      Thank you in advance!

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: ShowPopupDialog Freezes Cinema R21

      @m_adam
      Morning Maxime,

      Yes, it freezes with the code I provided.
      I've also tried the way that you mention above by running the c4d.SpecialEventAdd(1055684) and the same happens, as per my video below.

      https://drive.google.com/file/d/1v4A9xXKb79Z1TlMnlSdZ-tk9WJFldsv7/view?usp=sharing

      Let me know if you need any other information.

      Thank you!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: ShowPopupDialog Freezes Cinema R21

      @m_adam
      Hi Maxime,

      Cinema R21.207 Build RB303831.
      Windows 10 1809

      I'm calling the SpecialEventAdd on an SceneLoaderPlugin.

      # Import modules
      import c4d
      
      plugin_ID = 1055684
      
      
      class AOLoader(c4d.plugins.SceneLoaderData):
          """
          Class for the SceneLoaderData plugin.
          """
      
          def Identify(self, node, name, probe, size):
              """
              Identifies if the format of the custom file captured meets the plugins requirements.
              :param node: BaseContainer for instance.
              :param name: Path and file name of the instance.
              :param probe: The data from the instance.
              :param size: The data size of the instance.
              :return: True if meets object requirements.
              """
      
              file_name = name.lower()
      
              if not file_name.endswith('.ao'):
                  return False
      
              return True
      
          @staticmethod
          def clean_path_str(txt, chr_lst):
              """
              This method removes specific characters in a path.
              :param txt: The string to replace character.
              :param chr_lst: The characters list to be replaced.
              :return: Returns the path with removed c characters.
              """
      
              for c in chr_lst:
                  txt = txt.replace(c, '')
      
              return txt
      
          def read_lines(self, data_file):
              """
              Iterates throught the data until finds the line with path for .c4d asset.
              :param data_file: The file data returned by Identify method.
              :return: The path string, not formatted.
              """
      
              with open(data_file, 'rU') as data:
      
                  ds_file = data.read().splitlines()
                  paths = ""
      
                  for line in ds_file:
                      if ".c4d" in line:
      
                          remove_chrs = self.clean_path_str(line, [')', '"'])
                          paths += remove_chrs.replace("\\\\", "\\")
      
                  return paths
      
          def Load(self, node, name, doc, filterflags, error, bt):
              """
              Loads the data into the active document. In this case, we do not load or merge the file, but
              send a message to CoreMessage when it is catched with a SpecialEventAdd.
              The WorldContainer will save the path to be used later.
              :param node: BaseContainer for the instance.
              :param name: Path and file name of the instance.
              :param doc: The active document.
              :param filterflags: Flags to filter objects to load.
              :param error: Errors brought by Identify Method.
              :param bt: The BaseThread for the document.
              :return: Returns a c4d.FILEERROR_USERBREAK to capture the message.
              """
      
              paths = self.read_lines(name)
      
              world_container = c4d.GetWorldContainerInstance()
              world_container.SetString(plugin_ID, paths)
              c4d.SpecialEventAdd(plugin_ID)
      
              return c4d.FILEERROR_USERBREAK
      
      
      if __name__ == "__main__":
      
          c4d.plugins.RegisterSceneLoaderPlugin(id=plugin_ID,
                                                str="AO Loader",
                                                g=AOLoader,
                                                info=c4d.PLUGINFLAG_SCENELOADER_MERGEORIGINAL,
                                                description="")
      

      It's passing the data correctly, so perhaps the call needs to be done somewhere else?

      Thank you in advance!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos
    • ShowPopupDialog Freezes Cinema R21

      Hi all,

      Hope you are well in these crazy times!

      I'm having trouble understanding how ShowPopupDialog currently works in R21, if caught by MessageData plugin's CoreMessage. It keeps freezing Cinema, could be thread related (which I don't know a lot of)?

      I manage to get the data across externally fine but when creating the menu it freezes immediately after c4d.gui.ShowPopupDialog is called.

      # Import modules
      import os
      import c4d
      from c4d import documents
      
      plugin_ID = 1055685
      plugin_ID_loader = 1055684
      
      MENU_ADD_ASSETS = c4d.FIRST_POPUP_ID
      MENU_ADD_MATERIALS = c4d.FIRST_POPUP_ID + 1
      MENU_REPLACE_ASSETS = c4d.FIRST_POPUP_ID + 2
      MENU_REPLACE_MATERIALS = c4d.FIRST_POPUP_ID + 3
      MENU_REPLACE_TAG = c4d.FIRST_POPUP_ID + 4
      
      
      class AOMessage(c4d.plugins.MessageData):
          """
          Class for the MessageData plugin.
          """
      
          def GetTimer(self):
              """
              Called to return a time in milliseconds to receive timer messages (MSG_TIMER) with that interval in CoreMessage.
              This method is queried again after each message..
              :return: The time in miliseconds.
              """
              return 0
      
          def CoreMessage(self, id, bc):
              """
              Called to receive core messages.
              :param id: The id of the messages received.
              :param bc: The BaseContainer objects with message data.
              :return: True if Message is received.
              """
      
              if id == plugin_ID_loader:
      
                  world_container = c4d.GetWorldContainerInstance()
                  doc = documents.GetActiveDocument()
                  paths_str = world_container.GetString(plugin_ID_loader)
                  paths_lst = paths_str.split(', ')
                  active_objs = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
                  active_mat = doc.GetActiveMaterial()
                  doc.StartUndo()
      
                  # Dialog for importing assets
                  menu = c4d.BaseContainer()
      
                  if active_objs or active_mat:
                      menu.InsData(MENU_REPLACE_ASSETS, 'Replace Asset(s)')
                      menu.InsData(MENU_REPLACE_MATERIALS, 'Replace Material(s)')
                      menu.InsData(MENU_REPLACE_TAG, 'Replace Texture Tag(s)')
      
                  else:
                      menu.InsData(MENU_ADD_ASSETS, 'Add Asset(s)')
                      menu.InsData(MENU_ADD_MATERIALS, 'Add Material(s)')
      
                  result = c4d.gui.ShowPopupDialog(cd=None, bc=menu, x=c4d.MOUSEPOS, y=c4d.MOUSEPOS)
      
                  doc.EndUndo()
                  world_container.RemoveData(plugin_ID_loader)
      
                  print("Finished")
      
              return True
      
      
      if __name__ == "__main__":
      
          c4d.plugins.RegisterMessagePlugin(id=plugin_ID,
                                            str="AO Message",
                                            info=0,
                                            dat=AOMessage())
      

      It works perfectly in R19, so I'm not sure what changed since then.
      Apologies if this as been asked before.

      Thank you very much for your help in advance!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: Add and Remove Edge Loops Poly Object

      Hi @r_gigante,

      Not to worry! I understand! 😃

      Thanks for your help!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: Add and Remove Edge Loops Poly Object

      Hi @zipit,

      I am somehow even more confused than before, lol. You want the geometry in the screenshot to be subdivided, right? And the geometry is somehow procedurally generated by a Xpresso rig?

      I'm sorry if it made it more confusing! 😄
      The Xpresso just connects the userdata to the generator object. So the subdivisions are controlled by changing the object's number of segments.

      I do not quite understand why you cannot just implement that choice of subdivision in that rig? Doing it after the fact seems incredible cumbersome because this is probably not a static polygon mesh, but some kind of generator object that your rig produces there.

      That's correct! Which leads me to think that having a poly object in the first place is probably the best way.

      I am also just seeing now that you are asking also for a unsubdiving feature in your first post, which is quite a can of worms for an arbitrary mesh. I would go for your LOD-thingy if you see there a solution, because it is probably the fastest solution for you.

      Yes, that's what I currently testing. I agree as that being the best way to switch from different resolutions.
      Hopefully, this will work.

      Will keep you posted!

      Thanks again!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: Add and Remove Edge Loops Poly Object

      Hi @Cairyn,

      Does your setup react to the global Level of Detail controls?

      I'm afraid not! It's all done by changing the number of segments for the objects.

      If not, could you use a local LOD object with differently subdivided children?

      I'm currently exploring this. I think I will be able to do that. Need to make sure it it does not break with the rest of setup :)
      Will keep you posted!

      Cheers!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos
    • RE: Add and Remove Edge Loops Poly Object

      Hi all,

      Thank you very much for your help and apologies for the slow reply (been off a few days)!

      You are absolutely right, my question is too broad.
      Had a few days to think about other options and perhaps I'm overthinking this.

      Nevertheless, I will share with you the specifics.

      • Use of 3 basic (procedural) shapes: cube, tube and cylinder.
      • Shapes require to be changed dynamically to meet artists needs and required shapes. For example, a tube should be able to bend meet a 0, 90 and 180 degrees angle, without losing volume, while still be able to be shaped with secondary controls.
      • Animators will need to use the rig to make the changes to this shape with all necessary controls. This could be with user data sliders or splines.
      • Poly Counts needs to change depending on the shot and render software (Unreal or Cinema)

      So this is the current rig:
      d7fb9676-ae41-4f7c-b75d-55c808201299-image.png
      You have a dynamic change of shapes that supports all the parameters that you see in the image.
      It does lack the secondary controls needed to shape it as we want and this is a big point as I currently can't create the nuances with Xpresso.

      A possible solution would be to use three poly objects with different levels of subdivisions that are controlled with the same rig. Keep some elements procedural, as the bevel and bend deformers and connected all by Xpresso.
      This would give us the benefit of accessing the point information and deformed it manually for animation as we need.

      Also as @zipit said, this can also be a potential design, if rest fails

      And last but not least, a Python Tag doesn't seem to be the right choice for this kind of tool in the first place, due to its constant execution. A script manager script, a Python Generator Object or a fitting plugin type would be much appropriate choices.

      I understand that this is a design question and not API, so please delete if it's inappropriate. ☺

      Will come back with some results!

      Thank you all again for your time!

      Andre

      posted in Cinema 4D Development
      A
      AndreAnjos