I want to make walls and a sloped floor

I am creating a sloped trench using Python code.

When I select a path, a trent with a slope along that path is created. I intended to make the walls and floor editable, but I discovered that DirectShape cannot be modified.

Is there a way to generate a sloped floor and walls that attach to it? I would appreciate it if you could at least provide the production flow.

I will leave the code I used here in case it might be helpful.

import clrclr.AddReference(‘ProtoGeometry’)from Autodesk.DesignScript.Geometry import *

curve_input = IN[0]

if isinstance(curve_input, list):curve = curve_input[0]else:curve = curve_input

width = IN[1]bottom_thk = IN[2]slope = IN[3]offset = IN[4]base_level = IN[5]

wall control

wall_thk_L = IN[6]wall_thk_R = IN[7]wall_height_L = IN[8]wall_height_R = IN[9]

slope direction

flip_slope = IN[10]  # True = direction

count = 40

parameter

if curve.IsClosed:params = [i/float(count) for i in range(count)]else:params = [i/(count-1) for i in range(count)]

floor_sections = wall_L_sections = wall_R_sections = 

for i, t in enumerate(params):

pt = curve.PointAtParameter(t)

if curve.IsClosed:
    ratio = i/float(len(params))
else:
    ratio = i/float(len(params)-1)

# =========================
# 🔥 slope direction
# =========================
if flip_slope:
    ratio = 1 - ratio

dist = curve.Length * ratio
bottom_offset = slope * dist

tan = curve.TangentAtParameter(t).Normalized()
up = Vector.ZAxis()

side = tan.Cross(up)
if side.Length < 0.001:
    side = Vector.XAxis()
else:
    side = side.Normalized()

base_pt = pt.Add(side.Scale(offset))

# =========================
# coordi
# =========================

# floor (slope )
origin_floor = Point.ByCoordinates(base_pt.X, base_pt.Y, base_level - bottom_offset)

# wall
origin_wall = Point.ByCoordinates(base_pt.X, base_pt.Y, base_level)

cs_floor = CoordinateSystem.ByOriginVectors(origin_floor, side, tan, up)
cs_wall = CoordinateSystem.ByOriginVectors(origin_wall, side, tan, up)

def LF(x, y, z):
    return Point.ByCoordinates(x, y, z).Transform(cs_floor)

def LW(x, y, z):
    return Point.ByCoordinates(x, y, z).Transform(cs_wall)

# =========================
# 1️⃣ floor
# =========================
floor_pts = [
    LF(-width/2, 0, -bottom_thk),
    LF(width/2, 0, -bottom_thk),
    LF(width/2, 0, 0),
    LF(-width/2, 0, 0)
]
floor_sections.append(PolyCurve.ByPoints(floor_pts + [floor_pts[0]]))

# =========================
# 2️⃣ wall_l
# =========================
wall_L_pts = [
    LF(-width/2, 0, 0),
    LW(-width/2, 0, wall_height_L),
    LW(-width/2 + wall_thk_L, 0, wall_height_L),
    LF(-width/2 + wall_thk_L, 0, 0)
]
wall_L_sections.append(PolyCurve.ByPoints(wall_L_pts + [wall_L_pts[0]]))

# =========================
# 3️⃣ wall_r
# =========================
wall_R_pts = [
    LF(width/2, 0, 0),
    LW(width/2, 0, wall_height_R),
    LW(width/2 - wall_thk_R, 0, wall_height_R),
    LF(width/2 - wall_thk_R, 0, 0)
]
wall_R_sections.append(PolyCurve.ByPoints(wall_R_pts + [wall_R_pts[0]]))

=========================

Loft

=========================

floor_solid = Solid.ByLoft(floor_sections)wall_L_solid = Solid.ByLoft(wall_L_sections)wall_R_solid = Solid.ByLoft(wall_R_sections)

OUT = floor_solid, wall_L_solid, wall_R_solid

Hi 형,

This is more a brainstorming than a final solution.

I think using a family would probably be easier but to answer your questions, you could create a floor by a closed loop of curves (planar only) [2], create points along its edges, based on your slope, move the points Z values up (or down) until you reach the final level (Floor.AddPoint) [3].

(The point along the edges in my script are not ordered properly so the result is quite messy but it’s just to give you an idea.)

You may also try to use Ramp elements and see if it’s easier.

You can use the same curve loop to create walls and attaching them to a floor should be straightforward.

Trench01.dyn (56.2 KB)

.