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. vwgamedev
    V
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 4
    • Best 0
    • Controversial 0
    • Groups 0

    vwgamedev

    @vwgamedev

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

    vwgamedev Unfollow Follow

    Latest posts made by vwgamedev

    • Call "Set Deformed Mesh" on Weight Tag

      Hello, I am currently trying to realize an asset pipeline for our game project that allows us to prepare our characters and clothes for processing in Unity.

      Basically I have found a clean way to do this in Cinema4D that I can do by hand and that leads to success.
      I create a few extra bones that we need and do some renaming. None of this is a big deal. But it is important that we then run the "Set Deformed Mesh". If I do this manually, everything works perfectly, but I just can't find a way to call this function directly in Python. I have found a way to set the button to "Set Deformed Mesh" but this does not "press" it.:

      def apply_deformed_mesh(meshes):
          """
          Apply 'Set Deformed Mesh' on all meshes with weight tags.
          """
          for obj in meshes:
              weight_tag = obj.GetTag(c4d.Tweights)
              if weight_tag:
                  bc = weight_tag.GetDataInstance()
                  
                  # Set the button to 'Set Deformed Mesh'
                  bc.SetInt32(c4d.ID_CA_WEIGHT_TAG_SET_BUTTON, c4d.ID_CA_WEIGHT_TAG_SET_DEFORMED_MESH)
      
                  weight_tag.Message(c4d.MSG_UPDATE)
      
          # Update the scene
          c4d.EventAdd()
      

      Is there a way to execute this command somehow to automate the whole thing?

      posted in Cinema 4D SDK 2024 python windows
      V
      vwgamedev
    • Automatic UV Rectangularize / MDATA_UVRECTANGULARIZE

      I am currently trying to find out if it is possible to run the UV Rectangulize function via Python. I can only find two references to it in the entire Python SDK MDATA_UVRECTANGULARIZE_ALIGN: int = 2280
      MDATA_UVRECTANGULARIZE_EQUIDISTANT: int = 2281
      and this reference in the Cinema4D C++ SDK
      Unfortunately these are not mentioned in any way in the documentation and I don't understand to which c4d.MCOMMAND_* they belong.

      Basically I built a script that returns each UV island as a BaseSelect, now I want to iterate over this list of BaseSelect and try to apply the rectangulize for each island. I want to avoid doing this via c4d.CallCommand(1055347) if there is another way, especially because the method via CallCommand displays the dialog box with the message in the GUI for a UV island that cannot be rectangulated and this would obviously be extremely annoying in an automated plugin.

      posted in Cinema 4D SDK
      V
      vwgamedev
    • RE: UVCOMMAND_RELAX does not use the RELAXUV_EDGESEL_POINTER

      @ferdinand
      Thank you for the hint and the superfast response! I was not aware that these symbols dissolve into these numbers, which of course makes it much easier to work with them now. I was able to solve it with CallUVCommand:

          settings = c4d.BaseContainer()
          settings[c4d.RELAXUV_KEEP_BORDER] = False
          settings[c4d.RELAXUV_KEEP_NEIGHBORS] = False
          settings[c4d.RELAXUV_KEEP_POINTSEL] = False
          settings[c4d.RELAXUV_CUT_EDGESEL] = True
          settings[c4d.RELAXUV_EDGESEL_POINTER] = edge_sellection
          settings[c4d.RELAXUV_MAX_ITERATIONS] = 1
          settings[c4d.RELAXUV_MODE] = c4d.RELAXUV_MODE_ABF
          ret = c4d.modules.bodypaint.CallUVCommand(handle.GetPoints(),
                                                    handle.GetPointCount(),
                                                    handle.GetPolys(),
                                                    handle.GetPolyCount(),
                                                    uvw,
                                                    handle.GetPolySel(),
                                                    handle.GetUVPointSel(),
                                                    obj,
                                                    handle.GetMode(),
                                                    c4d.UVCOMMAND_RELAX,
                                                    settings)
      
      posted in Cinema 4D SDK
      V
      vwgamedev
    • UVCOMMAND_RELAX does not use the RELAXUV_EDGESEL_POINTER

      Hello,

      I would like to use UV Relaxing and in particular pass the current edge selection via RELAXUV_EDGESEL_POINTER to create UV seams on the selected edges.

      Basically the script does the UV Relaxing and I can see this clearly in the UV Editor Window, it doesn't report any errors and the res of SendModelingCommand() also returns True. Also I check via print(edge_selection.GetCount()) if my selection is passed at all and the count always matches the current edge selection. However, the relaxing does not use the edge selection as it would work in UV Manager via the UV Relaxing tab.

      I also found an older thread from 2016 mentioning that RELAXUV_EDGESEL_POINTER expects a string reference to a selection tag, although the SDK clearly indicates that a c4d.BaseSelect is expected, of course I tried that too, but that also remains unsuccessful.

      from typing import Optional
      import c4d
      
      doc: c4d.documents.BaseDocument  # The active document
      op: Optional[c4d.BaseObject]  # The active object, None if unselected
      
      def main() -> None:
          Unwrap(op)
      
      def Unwrap(obj: c4d.BaseObject):
          if not isinstance(obj, c4d.PolygonObject):
              return None
          
          edge_selection = get_selected_edges(obj)
          print(edge_selection.GetCount())
          # Set up the settings for the UV unwrapping.
          settings = c4d.BaseContainer()
          settings[c4d.RELAXUV_KEEP_BORDER] = False
          settings[c4d.RELAXUV_KEEP_NEIGHBORS] = False
          settings[c4d.RELAXUV_KEEP_POINTSEL] = False
          settings[c4d.RELAXUV_CUT_EDGESEL] = True
          settings[c4d.RELAXUV_EDGESEL_POINTER] = edge_selection
          settings[c4d.RELAXUV_MAX_ITERATIONS] = 0
          settings[c4d.RELAXUV_MODE] = 0
      
          # Execute the UV unwrapping command.
          res = c4d.utils.SendModelingCommand(command=1053624,
                                              list=[obj],
                                              mode=c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
                                              bc=settings,
                                              doc=doc)
          print(res)
          c4d.EventAdd()
      
      
      
      def get_selected_edges(obj):
          if not isinstance(obj, c4d.PolygonObject):
              return None
      
          neighbor = c4d.utils.Neighbor()
          neighbor.Init(obj)
      
          return obj.GetSelectedEdges(neighbor, c4d.EDGESELECTIONTYPE_SELECTION)
      
      """
      def state():
          # Defines the state of the command in a menu. Similar to CommandData.GetState.
          return c4d.CMD_ENABLED
      """
      
      if __name__ == '__main__':
          main()
      
      
      posted in Cinema 4D SDK s26 python windows
      V
      vwgamedev