I have an object that I need to remove many holes from and was wondering how to do this with a script. Here is one of the “plates” that I need to remove the holes from. The object has about 50 of these, at various locations and this is one of the simpler plates, which is why I’m look toward a script to do the heavy lifting for me. I can select all the co-planar faces then run the script.
You could also select all the holes and scale them to zero ([Alt][b][b] select + [S] + [W]->remove doubles) This should work fine in this case. You may want to do this at 2-3 points though (see the 3 center-points in your second image).
I’d really like to be able to do this in a script since I have many 1000s (yes thousands) of holes to remove from the full assembly I am working with (it’s got over 1,000,000 vertices in it) and selecting them by hand would be very time consuming.
What I am currently thinking is that if I can detect the outer edge loop of the plate then I can find all the other edges with only one face and this will give me the candidate list for the interior holes. I then group the edges together into loops and then merge them and poly reduce the plate. I hope that all made sense
The part I’m stuck on is figuring out what the outside edge of the plate in python.
If you really wanted to do it via Python, you’d be better off to just model the shape you want and then have python find one corner of the object with holes, and duplicate the model you want to replace the one with holes to that proper position. From there, you just have to delete the original mesh with holes.
If you want the general solution (for instance, if all plates aren’t the same shape), its probably going to be harder. To generically detect the outer vertices, you need to find one and then follow its edges (since it will be connected to all other outer vertices in a chain). Just take the most extreme values (smallest and largest positions) of its edge neighbors, and then repeat the process.
Better yet, you can take the edge from the previously found outer vertex, and look through the current vertex’s edges for the edge that makes the largest angle away from it (there may be some tricky trig here with CW vs CCW, not 100% sure, even though either way it should be the largest angle), since this would be the next most outer edge.
You might also want to look in the Blender source at edge loop finding code. It could be a big help (more so than what I just said :eek:).
I may have the answer. This could work for the holes on one plane at a time.Deselect all the vertices on the mesh, then just select all of the holes on a plane. Select them all at once. Set your pivot type to cursor and move the cursor to a point where they can all be merged. Then just scale them all down to this point. Alt-M to remove doubles. If you have indentations around the edge of the plane that could cause problems, it may need to be done recursively removing different sets of holes in stages.
Maybe if you could post the blend file or a rendered image of the object, someone might be able to make a suggestion. One idea is that if the geometry is too complicated, you could always just use ALT-B to simplify first.
To give a bit more background on this problem. I am just given the assemblies from a CAD system and I need to reduce the complexity to make them usable in Blender for others to examine who don’t have the CAD software. I can still represent the assembly without all the holes to give a usable “reduced detail version” and that will greatly reduce the face, vertex, edge count.
This particular assembly I have is very complex and the plates are all different sizes, shapes, angles and they sometimes change it on me so I need go back an remake the “reduced detail version”, which to me implies script instead of a manual process.
forTe. Thanks for the thoughts. I understand exactly what you are saying. Do you know where to find the source code for the edge loop finding code to look at?
This works but it is the opposite of the problem I am trying to solve. I already have the mesh with all the holes and faces in it and I need to remove them to make the mesh simpler.
And this is just one plate of the full assembly I need to deal with. The full assembly is a 44Meg blend file. I checked the sizes again and there are over 1,000,000 vertices and 345,00 faces in it. :spin:
That is why I need to use a script and let in grind away at it so I don’t have to manually do the simplification.
I’m getting these assemblies from a CAD system used to design the parts for manufacturing them. This particular assembly is a power supply and has lots of cooling holes which is why it’s so big.
I need to be able to display the parts to others. And they don’t have a CAD system so using Blender is a good choice since it’s free! But the assemblies are so big, it hard to work with them hence the need to reduce the level of detail in them.