Copy to primitives

   4871   5   1
User Avatar
Member
378 posts
Joined: Nov. 2010
Offline
I've been searching a while for that but couldn't find anything:

Is there a method to copy objects to primitive centers instead of points?

thanks
User Avatar
Member
8520 posts
Joined: July 2007
Online
not directly, but it's easy to do
just use Attrib Wrangle, switch Run Over parm to Primitives and use this code to create centroid point per primitive:
addpoint(0,@P);
removeprim(0, @primnum, 1);
if you want your point to inherit some attributes from geometry, you can use primuv() for that:
int pt = addpoint(0,@P);
vector nml = primuv(0, “N”, @primnum, {.5,.5,0});
setpointattrib(0, “N”, pt, nml);
removeprim(0, @primnum, 1);
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
378 posts
Joined: Nov. 2010
Offline
Thanks Tomas, that's exactly what I was looking for. Great!
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
although the best way is to use Attrib Wrangle SOP , but you have some other options for doing that , Also if you wanna add a point in center of each object or piece (e.g Fractures) , you should use another method , I made these methods for you.
:wink:

Attachments:
JKCentroid.hip (261.5 KB)

https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
378 posts
Joined: Nov. 2010
Offline
Hey Joker, thanks a lot! Sorry, I just saw your post today. Much appreciated

Edit: foreach is a killer node! :shock:
User Avatar
Member
8520 posts
Joined: July 2007
Online
if the fragments are packed primitives, you can just use Add SOP and remove primitives but keep the points
it will keep the centroids of the fragments and all the point attributes from packed prim
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links