I wrote the following code for a python SOP that removes duplicate lines. The basic idea is that it finds the mid-point of each line, and stores it in an array. If the mid-point already exists in the array, it adds the line to an array of lines to be deleted and then deletes them.
It was more a proof of concept, as I was hoping to write something equivalent but faster in VEX. To my horror, my VEX really chugged. I was using groups and inpointgroup to store and search for the results, but it was incredibly slow.
node = hou.pwd() geo = node.geometry() r = 3 centres = [] deletes = [] for i in geo.prims(): pts = i.points() x0,y0,z0 = pts[0].position() x1,y1,z1 = pts[1].position() centre = (round((((x1-x0)*0.5)+x0),r), round((((y1-y0)*0.5)+y0),r), round((((z1-z0)*0.5)+z0),r)) if centre in centres: deletes.append(i) else: centres.append(centre) geo.deletePrims(deletes, keep_points = False)
So I was just wondering if there was anyone out there who can give me some pointers on writing it in VEX.
That's unless of course, I have stumbled upon an instance of Python that runs faster than VEX…
Ash