擅长:python、mysql、java
<p>通常情况下,您希望使用如下序列来执行此操作:</p>
<ol>
<li>将当前选择转化为边</li>
<li>将polySelectConstraint应用于选择以筛选它</li>
<li>重置“polySelect”约束,使其不会影响将来的选择</li>
</ol>
<p>编写这个函数是个好主意,这样它就不会改变选择,因为很容易意外地取消选择值不好的对象。最低版本应该是这样的(注意它如何在最后重置选择)</p>
<pre><code>def edges_by_angle(selection, min_angle, max_angle):
'''return the edges in selection with a crossing angle between <min_angle> and <max_angle>'''
result = []
try:
edges = cmds.polyListComponentConversion(selection, te=True)
cmds.select(edges)
cmds.polySelectConstraint(mode =3, type = 0x8000, a = 1, ab = (min_angle,max_angle))
result = cmds.ls(sl=True) or []
finally:
cmds.polySelectConstraint(dis=True)
cmds.select(selection)
return result
</code></pre>
<p>您可以通过使用<code>intFieldGrp</code>而不是两个<code>intFields</code>来简化GUI。养成在函数中构建gui的习惯是个好主意,上面所写的代码可以在监听器中工作,但是如果从模块文件导入,它的行为会很奇怪。将东西放入函数中是一种控制变量范围的廉价方法,因此不难找出需要的回调函数在哪里。下面是一个非常简单的例子:</p>
^{pr2}$
<p>您可以将<code>edges_by_angle()</code>函数与此分开,因为它在其他情况下可能很有用。在</p>