2
$\begingroup$

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.

enter image description here enter image description here

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...

$\endgroup$
  • $\begingroup$ try delete with limited dissolve and which other software u used to make that svg $\endgroup$ – atek Oct 16 '17 at 14:36
  • $\begingroup$ "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. $\endgroup$ – Duarte Farrajota Ramos Oct 17 '17 at 0:26
2
$\begingroup$

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
from math import radians, degrees
MIN_ANGLE = radians(5)
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):
    if len(v.link_edges) != 2:
        return False
    e1, e2 = v.link_edges[:]
    v1 = e1.other_vert(v).co - v.co
    v2 = e2.other_vert(v).co - v.co
    return v1.angle(-v2) >= radians(MIN_ANGLE)

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()
| improve this answer | |
$\endgroup$
  • $\begingroup$ Once again, thank you @batFINGER for clear examples! $\endgroup$ – zippy Jun 1 at 0:59
3
$\begingroup$

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.)

Convert your Curve Object to a Mesh Object

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).

Selecting similar face angles

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).

Deleting unneeded vertices from the side

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.

Dissolving all vertices that aren't corners

Here is the result:

Result of dissolving the unneeded vertices, leaving only the corners

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.)

Removing doubles for non-right angles

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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ 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! $\endgroup$ – Inkplay_ Oct 16 '17 at 19:34
  • $\begingroup$ 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. $\endgroup$ – Mentalist Oct 17 '17 at 0:54
  • 1
    $\begingroup$ They complement each other. 8^) $\endgroup$ – batFINGER Oct 17 '17 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.