LoginSignup
2
0

mayaでハードエッジを抽出したい

Last updated at Posted at 2023-07-17

ハードエッジを抽出したいなー

抽出した後にあれこれやりたいなー

とりあえず検索

  • select > Use Constraints で選択

よくつかいますねー
ただスクリプトで処理したいですねー

  • polySelectConstraint を使う

うん・・・・うーんなんかこう・・・・ちがう

APIでなんかあんじゃね?

いつもどおりほげーっとapiのリファレンスを眺めてみると

OpenMaya.MFnMesh.isEdgeSmooth()
isEdgeSmooth(edgeId) -> bool
Returns True if the edge is smooth, False if it is hard.

あ、これっぽいな。

とりあえず試す

あーこんな感じかなぁ

import maya.api.OpenMaya as om
def getHardEdges(target):
    sellist = om.MGlobal.getSelectionListByName(target)
    dagPath = sellist.getDagPath(0)
    FnShape = om.MFnMesh(dagPath)        
    edgeNum = FnShape.numEdges

    hardIDs = []
    for edgeID in range(0,edgeNum):    
        if FnShape.isEdgeSmooth(edgeID)==False:
            hardIDs.append(target + ".e["+str(edgeID)+"]")

    return hardIDs

こんな玉を用意して
image.png

実行

cmds.select(getHardEdges("pSphere1"),r =True)

結果
image.png

お?問題なく動いたっぽいな

疑問

isSmoothってあるけど、smoothとhardの境目ってどこなんだろな
それはまたの機会に考えよう

2
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
2
0