Day 15
(3.5)
スパイラル状に回転+拡大するArc - 折り込む
#curve#transform#3d#structure

✅ Inputs
- arc_angle_deg: float – 元のArcの開き角度(度)
- num_copies: int – Arcを複製する数
- total_rotation_deg: float – 全体で回転する角度(度)
- final_scale: float – 最後のArcのスケール倍率(最初は1.0)
- radius: float – 元のArcの半径
- offset: float – 内側へのオフセット距離
- start_angle_degree: float – Arcの開始角度(度)
- end_angle_degree: float – Arcの終了角度(度)
✅ Outputs
- results: list of Brep – 二重構造のLoftで生成されたシェル形状群
✅ Code
# === 🔧 入力パラメータ例 ===
# num_copies = 50
# total_rotation_deg = 500
# final_scale = 4.5
# radius = 100.0
# offset = 50.0
# start_angle_degree = -30
# end_angle_degree = 90
import Rhino.Geometry as rg
import math
plane_xz = rg.Plane.WorldZX
circle = rg.Circle(plane_xz, radius)
start_angle = math.radians(start_angle_degree)
end_angle = math.radians(end_angle_degree)
interval = rg.Interval(start_angle, end_angle)
arc = rg.Arc(circle, interval).ToNurbsCurve()
# === 🔁 Step 2 & 3: 回転 + スケール複製 ===
arcs = []
origin = rg.Point3d(0, 0, 0)
angle_step = math.radians(total_rotation_deg / num_copies)
for i in range(num_copies):
# 回転角
angle = i * angle_step
# スケール係数(線形補間)
t = float(i) / (num_copies - 1)
scale_factor = 1.0 + (final_scale - 1.0) * t
# トランスフォーム
rot = rg.Transform.Rotation(angle, origin)
scale = rg.Transform.Scale(origin, scale_factor)
# Arcの複製・変形
arc_copy = arc.DuplicateCurve()
arc_copy.Transform(scale)
arc_copy.Transform(rot)
arcs.append(arc_copy)
# === 📐 オフセット処理 ===
offset_arcs = []
for a in arcs:
offsets = a.Offset(rg.Plane.WorldXY, -offset, 0.001, rg.CurveOffsetCornerStyle.Sharp)
if offsets and len(offsets) > 0:
offset_arcs.append(offsets[0])
# === 🔄 Shift処理 ===
shifted_arcs = arcs[1:] # wrapしない
# === 🏗️ 二重構造Loft処理 ===
loft_breps = []
# 1. shifted_arcs × offset_arcs[:-1]
for i in range(len(shifted_arcs)):
c1 = shifted_arcs[i]
c2 = offset_arcs[i]
breps = rg.Brep.CreateFromLoft([c1, c2], rg.Point3d.Unset, rg.Point3d.Unset, rg.LoftType.Normal, False)
if breps: loft_breps.append(breps[0])
# 2. arcs × offset_arcs[:-1]
for i in range(len(arcs) - 1):
c1 = arcs[i]
c2 = offset_arcs[i]
breps = rg.Brep.CreateFromLoft([c1, c2], rg.Point3d.Unset, rg.Point3d.Unset, rg.LoftType.Normal, False)
if breps: loft_breps.append(breps[0])
results = loft_breps