[Sidefx-houdini-list] new points at center of poly faces

sgustafso at gmail.com sgustafso at gmail.com
Wed Mar 30 03:20:47 EDT 2011


One approach that's reasonably efficient:

Create a vector primitive attribute called 'center' with values $CEX,$CEY,$CEZ. When creating primitive attribs, the $CE[XYZ] vars refer to the primitive centroid.
Use a line sop with npoints set to nprims() to create your points, then delete the line prim but keep the points. This can be slightly more efficient that going through a copy sop (especially a copy sop with transforms!) for high point counts if you just need to create a bunch of points and move them later. ymmv.
Use a primattrib vop inside of a vopsop to apply the 'center' attribute to the points. primattrib expects a geometry file, but you can feed it an op path. I usually set the oppath with an expression like: "op:`oppwf()`/../SOURCE_GEOM[$FF]"

That should do it. So brief recap: attribcreate to get an attrib holding the centroid, whatever method you want to instantiate a bunch of points to move, then vopsop to set the positions.

Another trick for getting the centroids is to use attrib promotions. I.e,. create point attrib 'pos' set to $T[XYZ], then promote to a primitive attrib with the mode set to average, leaving you with an attrib holding the centroids. I've used this in the past before I realized that $CE[XYZ] would work, and it seemed to scale pretty well.

At Wed, 30 Mar 2011 17:33:36 +1000,
Rangi Sutton wrote:
> 
> add sop.. copy sop with nprims("../PRIM_SRC") in the num copies, and in
> translates use prim("../PRIM_SRC", $CY, "P", 0).
> 
> Make an asset. Forget about it. Maybe python does this better.
> 
> Actually, I think there's an asset in that toolbox that was posted the other
> day that does this.
> 
> scaling prims to zero does work though.. can be a problem if you have
> identical prims.. since they'll fuse.
> 
> Beers,
> r.
> 
> 
> 
> On 30 March 2011 17:24, Miles Green <Miles.Green at al.com.au> wrote:
> 
> > Hi,
> >  I need to efficiently get a new point at the center of all my current poly
> > faces..
> >
> > i'm sure there are multiple ways to do this, but my current method of :
> >
> > [input polygons]-->[facet(uniquepoints]->[primitive (scale to 0.001)]->
> > [fuse]
> >
> > is a little slow..
> >
> > any other suggestions appreciated
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list



More information about the Sidefx-houdini-list mailing list