0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

mayaがエラー・ワーニングを吐く時の対処 1 ~存在しないUVset~

Last updated at Posted at 2021-08-25

mayaがwarningを吐いて鬱陶しい時

メッシュデータをimportしただけでこんなワーニングを吐く時

Warning: The mesh object|objectShape contains invalid or unused components.  These can be cleaned up using the Mesh Cleanup dialog. #

場合にもよるけれども、指示通りにcleanup実行してもwarnigが出続ける場合がある。
そのケースの1つとして、不正なUVsetの存在(勝手に命名)があげられる。

不正なUVsetとは
UVsetNameは定義されていない(None)だが、UV座標情報がアトリビュートに残ってしまっているUVset

UVsetEditorからはもちろん見えないので、確認するにはnodeEditorかスクリプトで処理する必要がある。

まずUVsetNameを確認

import maya.cmds as cmds
uvSet_index = cmds.getAttr(node  + ".uvSet", mi =True)

for index in uvSet_index :
    uvSetName  = cmds.getAttr(node  + ".uvSet["+str(index)+"].uvSetName")

uvSetName が Noneでなければ、UVsetEditorに乗るので Noneじゃない場合はスルー

import maya.cmds as cmds
uvSet_index = cmds.getAttr(node  + ".uvSet", mi =True)

for index in uv_index:
    uvSetName  = cmds.getAttr(node  + ".uvSet["+str(index)+"].uvSetName")

    if uvSetName != None:
        continue

次にUVSetPoints(UV座標情報)がNoneか否かを判別
名前があって、UVセットが空の場合はそれはそれでワーニング出るので問題。

import maya.cmds as cmds
uvSet_index = cmds.getAttr(node  + ".uvSet", mi =True)

for index in uvSet_index:
    uvSetName  = cmds.getAttr(node  + ".uvSet["+str(index)+"].uvSetName")
    uvsetPoint_index = cmds.getAttr(node  + ".uvSet["+str(index)+"].uvSetPoints",mi =True)

    if uvSetName != None and uvsetPoint_index != None:
        continue

    elif uvSetName != None and uvsetPoint_index == None:
        print(node + " "  + uvSetName + " is  empty uvset")
        continue

    elif uvSetName == None and uvsetPoint_index == None:
        print(node + " has invalid uvset")
        continue

これで検知はできたとして、不正UVsetの除去方法を考える。
手っ取り早いのは、一度名前を与えて正規のUVset化した上で削除する

import maya.cmds as cmds
uvSet_index = cmds.getAttr(node + ".uvSet", mi =True)

for index in uvSet_index:
    name = cmds.getAttr(node  + ".uvSet["+str(index)+"].uvSetName")
    uvsetPoint_index = cmds.getAttr(node  + ".uvSet["+str(index)+"].uvSetPoints",mi =True)

    if name == None and uvsetPoint_index != None:
        cmds.setAttr(node + ".uvSet["+str(index)+"].uvSetName", "uvSet"+str(index) + "_reborn", type = "string")
        cmds.polyUVSet(node ,uvSet = "uvSet"+str(index) +"_reborn",delete=True)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?