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. ADCMHI
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    ADCMHI

    @ADCMHI

    0
    Reputation
    3
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    ADCMHI Unfollow Follow

    Latest posts made by ADCMHI

    • RE: How to run UVCOMMAND_OPTIMALCUBICMAPPING

      I'm sorry for posting without understanding the rules.
      Thank you for your response.
      I tried using this script, but it's not working properly. Could someone help me fix it?

      import c4d
      from c4d import utils
      
      def apply_optimal_cubic_uv(obj, doc):
          if obj.GetType() == c4d.Opolygon:
              # UVWタグがなければ作成
              if not obj.GetTag(c4d.Tuvw):
                  uvw_tag = c4d.UVWTag(obj.GetPolygonCount())
                  obj.InsertTag(uvw_tag)
      
              # オブジェクトを選択
              doc.SetActiveObject(obj, c4d.SELECTION_NEW)
      
              # 最適化されたキュービックUVマッピングを適用
              settings = c4d.BaseContainer()
              settings[c4d.OPTIMALMAPPING_PRESERVEORIENTATION] = True  # 向きを保持
              settings[c4d.OPTIMALMAPPING_STRETCHTOFIT] = False  # ストレッチフィット
              settings[c4d.OPTIMALMAPPING_TWOD] = False  # 2D最適化
              settings[c4d.OPTIMALMAPPING_AREAFAK] = 0.0
              settings[c4d.OPTIMALMAPPING_RELAXCOUNT] = 0  # リラックス回数
              settings[c4d.OPTIMALMAPPING_SPACING] = 0.02  # スペーシング
      
      
              res = c4d.modules.bodypaint.CallUVCommand(points,
              pointCount,
              polys,
              polyCount,
              uvw,
              polySelection,
              pointSelection,
              op=settings,
              handle.GetMode(),
              cmdid,
              settings)
                  #command=c4d.UVCOMMAND_OPTIMALCUBICMAPPING,
                  #list=[obj],
                  #mode=c4d.MODELINGCOMMANDMODE_ALL,
                  #bc=settings,
                  #doc=doc
              
      
              if not res:
                  print("Failed to apply optimal cubic mapping to {}".format(obj.GetName()))
      
      def main():
          doc = c4d.documents.GetActiveDocument()
          if not doc:
              return
      
          doc.StartUndo()
      
          objects = doc.GetObjects()  # シーン内の全オブジェクトを取得
          for obj in objects:
              apply_optimal_cubic_uv(obj, doc)
      
          doc.EndUndo()
          c4d.EventAdd()
      
      if __name__ == "__main__":
          main()
      
      posted in Cinema 4D SDK
      A
      ADCMHI
    • How to run UVCOMMAND_OPTIMALCUBICMAPPING

      @m_adam
      Hi!
      I'm trying to apply UVW mapping to child objects of an FBX file imported into Cinema 4D using this script.
      While I can assign UVW coordinates, the automatic cubic UV unwrapping isn't working. Can you advise on what modifications are needed to achieve this?

      import c4d
      from c4d import utils
      
      def apply_optimal_cubic_uv(obj, doc):
          if obj.GetType() == c4d.Opolygon:
              # UVWタグがなければ作成
              if not obj.GetTag(c4d.Tuvw):
                  uvw_tag = c4d.UVWTag(obj.GetPolygonCount())
                  obj.InsertTag(uvw_tag)
      
              # オブジェクトを選択
              doc.SetActiveObject(obj, c4d.SELECTION_NEW)
      
              # 最適化されたキュービックUVマッピングを適用
              settings = c4d.BaseContainer()
              settings[c4d.OPTIMALMAPPING_PRESERVEORIENTATION] = True  # 向きを保持
              settings[c4d.OPTIMALMAPPING_STRETCHTOFIT] = False  # ストレッチフィット
              settings[c4d.OPTIMALMAPPING_TWOD] = False  # 2D最適化
              settings[c4d.OPTIMALMAPPING_AREAFAK] = 0.0
              settings[c4d.OPTIMALMAPPING_RELAXCOUNT] = 0  # リラックス回数
              settings[c4d.OPTIMALMAPPING_SPACING] = 0.02  # スペーシング
              
      
              res = utils.SendModelingCommand(
                  command=c4d.UVCOMMAND_OPTIMALCUBICMAPPING,
                  list=[obj],
                  mode=c4d.MODELINGCOMMANDMODE_ALL,
                  bc=settings,
                  doc=doc
              )
      
              if not res:
                  print("Failed to apply optimal cubic mapping to {}".format(obj.GetName()))
      
      def main():
          doc = c4d.documents.GetActiveDocument()
          if not doc:
              return
      
          doc.StartUndo()
      
          objects = doc.GetObjects()  # シーン内の全オブジェクトを取得
          for obj in objects:
              apply_optimal_cubic_uv(obj, doc)
      
          doc.EndUndo()
          c4d.EventAdd()
      
      if __name__ == "__main__":
          main()
      
      posted in Cinema 4D SDK
      A
      ADCMHI