ChatGPT를 이용해 형상을 만들어 내는 것도 가능합니다. 블렌더 스크립트를 작성해서 가능한데요. 다음과 같은 명령어로 블렌더 스크립트를 제작하고 이를 실행하면 모양을 생성해 낼 수 있습니다.
- Create a wire as an extension of a cylindrical shape extending along the path. The path is along a rectangle. This path will be elevated by height by defined turns. Please do it for Blender script.
- You can use the Blender script to create a wire that follows a rectangular path while elevating by the specified turns. I also like the wire has bevel.
- It doesn’t have to be a strict rectangle shape. This code makes unnecessary lines between each rectangle. I want to eliminate the overlapping wire making smooth elevation.
- Can you omit the last coil side of each rectangle to avoid overlapping?
이와 같은 방법으로 다음과 같은 코드를 생성합니다.
import bpy
import math
def create_wire_curve(name, rect_dims, turns, segments, bevel_radius):
angle = 2 * math.pi / segments
control_points = []
width, length, _, height = rect_dims
for i in range(segments * turns):
t = (i / segments) % 1
side = i // segments % 4
if side == 0:
x = width / 2
y = (length / 2) * (1 – 2 * t)
z = (i / segments) * height
elif side == 1:
x = (width / 2) * (1 – 2 * t)
y = -length / 2
z = (i / segments) * height
elif side == 2:
x = -width / 2
y = (-length / 2) * (1 – 2 * t)
z = (i / segments) * height
else:
continue
control_points.append((x, y, z))
curve_data = bpy.data.curves.new(name, ‘CURVE’)
curve_data.dimensions = ‘3D’
curve_data.bevel_depth = bevel_radius
spline = curve_data.splines.new(type=’NURBS’)
spline.points.add(len(control_points) – 1)
for i, point in enumerate(spline.points):
point.co = control_points[i] + (1.0,)
spline.use_endpoint_u = True
spline.use_cyclic_u = False
curve_obj = bpy.data.objects.new(name, curve_data)
bpy.context.collection.objects.link(curve_obj)
return curve_obj
# Create the wire curve
wire_name = ‘Wire’
rect_dims = (10, 20, 0.5, 0.2)
turns = 20
segments = 24
bevel_radius = 0.1
wire_obj = create_wire_curve(wire_name, rect_dims, turns, segments, bevel_radius)
스크립트를 사용하여 원하는 결과를 얻을 수 있습니다.