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()