View in #maya on Slack
@douglascomet: Hi all, would anyone have any suggestions how to get the area/size of a UV Shell?
@bob.w: If you’ve got the shell’s faces selected sum(face.getUVArea() for face in pm.selected(fl=True))
@douglascomet: Oh damn, that was much easier than expected. I was googling to no avail
@passerby: yeah same way i have always handled it as well
@bob.w: Yeah, the getUVArea
method is one of those things that pymel pulls out of the API. There isn’t a super easy way to to just get that value with cmds
that I know of
@passerby: gets a pretty accurate area since its per face
vs trying to do your own bounds
i thought there was a cmds way
but i might be thinking off face area
yeah nvm i was tottally thinking of polyEvalulate for face area
pretty much pymel, or doing it with 4 times the amount of code in openMaya
@bob.w:
import maya.api.OpenMaya as om
sel = om.MGlobal.getActiveSelectionList()
dag, obj = sel.getComponent(0)
it = om.MItMeshPolygon(dag, obj)
areas = []
for i in range(it.count()):
it.next(it)
areas.append(it.getUVArea())
print(sum(areas))
For an example of the extra amount of code needed
But if your shells are super dense, this would be faster.
Also, thank you, couldn’t remember polyEvaluate
my brain kept jumping to polyInfo
sum(cmds.polyEvaluate([cmds.ls](http://cmds.ls)(sl=True), uvFaceArea=True))
Will do it through commands.
This should also be faster than pymel, given that it is two calls, it will probably be fairly close to the api speed.
@passerby: @bob.w which version i dont see that flag in the docs
@bob.w: 2018
@passerby: oh that is a new flag for polyEvalulate in 2018
@bob.w: Good to know!
@passerby: yeah not in 2017