1

I'd like to model a path that goes through a spiral-like, rounded square loop, then loops back out. I know about the Extra-Spiral tool, but that only gets me halfway through. I want to accomplish something like this

Spiral loop

Is there a way to accomplish that in an easy (and regular) way?

Enzo
  • 129
  • 4

3 Answers3

3

Script inspired by the bezier circle.

enter image description here Test runs

A default bezier circle has 4 points, with vertical handles on left and right horizontal handles top and bottom. Script below steps around the 4 quadrants adding a 2 point corner for a number of turns. The dimension of the spiral grows or diminishes by a set amount.

import bpy
from mathutils import Vector
context = bpy.context
# parameters
cr = 1 # corner radus
L = 4  # initial width
dL = -0.25 # shrink (grow -ve) factor
turns = 10 # number of turns in spiral

def add_bezier(pts):
    curve = bpy.data.curves.new('Curve', 'CURVE')
    spline = curve.splines.new('BEZIER')

    spline.bezier_points.add(count=len(pts) - 1)
    spline.bezier_points.foreach_set("co", [c for p in pts for c in p])
    x = cr * Vector((1, 0, 0))
    y = cr * Vector((0, 1, 0))
    lhs = (y, -x, -x, -y, -y, x, x, y)
    spline.bezier_points.foreach_set("handle_left", [c  for i,p in enumerate(pts) for c in p + lhs[i%8]])
    spline.bezier_points.foreach_set("handle_right", [c for p in pts for c in p])

    ob = bpy.data.objects.new('Curve', curve)
    spline.bezier_points[0].select_control_point = True
    return ob

corners = []
loc = Vector((-L / 2, -L / 2, 0))
for turn in range(turns):
    for sy in (1, -1):
        for sx in (sy, -sy):
            v = (sx * L, 0, 0) if sx == sy else (0, sy * L, 0)

            cverts = ((cr * sx, 0, 0), (0, cr * sy, 0))
            if sx == sy: cverts = reversed(cverts)
            corners.append([loc + Vector(p) for p in cverts])
            loc = loc + Vector(v)
        L -= dL

scene = context.scene   

pts = []  
for p in corners:
    pts.extend(p)
scene.objects.link(add_bezier(pts))
batFINGER
  • 84,216
  • 10
  • 108
  • 233
1

Curve Trace Inkscape does a fairly good job at bitmap tracing. The only problem is with double lines produced for each traced path. If you can minimize the thickness of the lines in the input image, then maybe you can break apart the traced image and remove one of the double segments (I can't go into more details since this is blender forum, but there are many tutorials out there on this topic :).

I got the above curve by auto-tracing (used Paint Bucket Tool actually) the image and then importing it into blender via svg import add-on.

Blender Dadaist
  • 1,559
  • 8
  • 15
1

The answer was way simpler than I expected.

I simply make one square spiral (Spiral Type: 2, Curve Type: 0, Steps: 4), then duplicate it, then connect the two inner ends with an S shape.

I'm only missing how to round the corners, but that's the idea.

Enzo
  • 129
  • 4
  • You probably have to ctrl-shift_B bevel the corners, with the percentage option, so the bevel is proportional to the edge length ,,,, Which tool are you using? I couldn't get a truly satisfactory result with Curve>Extra Objects.... – Robin Betts Oct 10 '18 at 13:18
  • 1
    I used that one, tilting it a little bit with Ctrl+T – Enzo Oct 10 '18 at 15:57
  • OK... and rather than duplicating .. I used the Offset Edges add-on to make my outward spiral..... before beveling – Robin Betts Oct 10 '18 at 16:28