# Sharpen mesh curves by dissolving vectors

I loaded a floor plan SVG file into Blender, this SVG file is made from another program automatically not by me. Any ways this new beveled curve I imported now has a lot of uneven bumps.

How do I "sand" these bumps off so I can have straight lines? There is no way I want to do this by hand. I know a decent amount of python and has been tinkering with blend's API before so I should be able to deal with this. The question is how? My idea is to turn these into meshes and check all the vertices locations for the entire mesh to identify huge groupings of vertices. After that I id these points, then I have to find one starting vertices and one ending vertices then just dissolve all the vertices in-between. Major issue is to find these 2 starting points. Any idea or thoughts on how to identify these 90 degrees corner vertices? Or maybe I am overthinking everything and there are simple ways to do this?

Edited: I could also just check the distance between one vertices to another, if its too tiny of a threshold/distance I know they are too close to each other. I can then store the measurement, at the end I can dissolve all the groupings together. I'm still not completely sure...

• try delete with limited dissolve and which other software u used to make that svg
– atek
Oct 16, 2017 at 14:36
• "this SVG file is made from another program automatically not by me" This is generally not a good idea, and you will end up wasting more time cleaning up the mess then if you, invested the time yourself create proper clean bases instead. Oct 17, 2017 at 0:26

Script Version

A corner vert is any vert v with angle of the vectors created from the other vert of each edge, ev1 and ev2. The vectors calculated as v1 = v.co - ev1.co and v2 = ev2.co - v.co.

Any vert with angle difference, v1.angle(v2) greater than MIN_ANGLE is considered a corner. I've put in 5 degrees as a default, change to suit. Run with mesh object in edit mode.

import bpy
import bmesh
context = bpy.context
obj = context.object
me = obj.data
#bm = bmesh.new()
#bm.from_mesh(me)
bm = bmesh.from_edit_mesh(me)
def is_corner(v):
return False
v1 = e1.other_vert(v).co - v.co
v2 = e2.other_vert(v).co - v.co

not_corners = [v for v in bm.verts if not is_corner(v)]
bmesh.ops.dissolve_verts(bm, verts=not_corners)
#bm.to_mesh(me)
me.update()

• Once again, thank you @batFINGER for clear examples! Jun 1, 2020 at 0:59

## In situations like this, Select Similar can save the day

As your intuition hinted to you, converting it to a mesh first (AltC) and dealing in vertices is the best approach.

(I'm including all keyboard shortcuts to be friendly to a general audience.)

Once that is done, in Mesh Edit Mode Select All with A and press W to Remove Doubles.

Then Extrude (E) upward on the Z axis (Z) so that you will have some face angles (I know, it's unfortunate that it doesn't work with edge angles).

With one corner edge selected you can then select all the 90-degree angles using Select Similar (ShiftG).

Add these selected corner vertices to a Vertex Group so that you can re-select them later. (Click the "+" button to create a new group, then the "Assign" button)

You can now delete the vertices that were created during extrusion. Selecting them from the front or side orthographic views and use Border Select (B). then Delete (X).

Use the trusty Vertex Group you created to call up the corner vertices. (Click the "Select" button)

Then invert your selection using CtrlI to select everything that is not a corner. From there it's just a matter of hitting X and choosing Dissolve Vertices.

Here is the result:

That concludes the solution for right angled corners.

For any regions that are not right angles, you can select their vertices separately and Remove Doubles (W) with a high Merge Distance threshold.

(You may want to avoid selecting the outermost vertices, because if they are collapsed during the merge operation the angles of the walls they comprise would change.)

Merge Distance can be set in the Operator Panel, so make sure it's visible (you may need to press T and drag that window area up from the bottom if it's not already visible).

The result after removing doubles at an increased merge distance:

In the above example, if you needed to eliminate the very short edge segments that remain, you could perform an Edge Slide (GG), slide the selected edge all the way toward the longer walls, select all relevant vertices, and Remove Doubles (W).

Each use case will of course be a little different, but with the tools I've described and a bit of ingenuity you should be good to go.

• Both you and @batFinger is freaking amazing, unfortunately I can only pick one answer and I found batFinger's more helpful to me. None the less thank you so much for putting in the effort to answer my question! I wish I can pick 2 best answers I really do! Oct 16, 2017 at 19:34
• No worries, glad you found it helpful! I hope it will be helpful to other readers as well. Some people prefer to approach problems with coding, while others prefer to use modeling tools. I happen to be in the latter category. Having two ways to approach the problem is a plus. Oct 17, 2017 at 0:54
• They complement each other. 8^) Oct 17, 2017 at 11:14