#%% from build123d import * from ocp_vscode import show import numpy as np #%% with BuildLine() as roller_coaster: powerup = Spline( (0, 0, 0), (50, 0, 50), (100, 0, 0), tangents=((1, 0, 0), (1, 0, 0)), tangent_scalars=(0.5, 2), ) corner = RadiusArc(powerup @ 1, (100, 60, 0), -30) screw = Helix(75, 150, 15, center=(75, 40, 15), direction=(-1, 0, 0), mode=Mode.PRIVATE) Spline(corner @ 1, screw @ 0, tangents=(corner % 1, screw % 0)) add(screw) Spline(screw @ 1, (-100, 30, 10), powerup @ 0, tangents=(screw % 1, powerup % 0)) show(roller_coaster) # %% with BuildPart() as coaster: thepath = powerup n = int(thepath.length/4) r0 = 90 r1 = 45 d = 2 d1 = 0.4 locs_l = ((-d/2.,0)) locs_r = ((d/2.,0)) p1 = Plane(thepath @ 0, z_dir=thepath % 0).rotated((r0,0,0)) p2 = Plane(thepath @ 1, z_dir=thepath % 1).rotated((r1,0,0)) with BuildSketch(p1) as sk: with Locations(locs_l): sl = Circle(d1) with BuildSketch(p1) as sk1: with Locations(locs_r): sr = Circle(d1) with BuildSketch(p2) as sk2: with Locations(locs_l): el = Circle(d1) with BuildSketch(p2) as sk3: with Locations(locs_r): er = Circle(d1) sweep(sections=[sk.sketch,sk2.sketch], multisection=True, path=thepath) sweep(sections=[sk1.sketch,sk3.sketch], multisection=True, path=thepath) for r, t in zip(np.linspace(r0,r1,n),np.linspace(0,1,n)): with Locations((thepath.location_at(t))): Box(d,0.2,0.3,rotation=(0,0,r)) show(coaster) # %%