I want to get the centroid xyz and normal xyz of a series of polygon.
I used the following in a python node but it didn't work…
prims = hou.pwd().geometry().prims()
for prim in prims:
x = prim.attribValue(“P”)
print x
advise is appreciated!
- Ji
how to use python to get centroid xyz of a polygon
11094 5 1-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- graham
- Member
- 1926 posts
- Joined: Nov. 2006
- Offline
-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
the use of the sum() function as explained in:
Code Like a Pythonista: Idiomatic Python
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html [python.net]
- Ji
Code Like a Pythonista: Idiomatic Python
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html [python.net]
- Ji
-
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
Keep in mind that for polygons other than triangles and parallelograms, that gets you the centroid if the mass is equally distributed among the vertices, not the centroid if the mass is equally distributed over the area, which is a lot harder to compute. Of course, for many purposes, it doesn't matter which you use; just thought I'd let ya know!
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
-
- Quick Links

