A3. Visualize
Ex 1. Draw Forces
# ==============================================================================
# Draw Forces
# ==============================================================================
scale = 0.01
tol = 0.001
lines = []
for u, v in thrust.edges_where({'_is_edge': True}):
force = thrust.edge_attribute((u, v), '_f')
sp, ep = thrust.edge_coordinates(u, v)
radius = scale * force
if radius < tol:
continue
lines.append({
'start': sp,
'end': ep,
'radius': radius,
'color': (255, 0, 0),
'name': "{}.force.{}-{}".format(thrust.name, u, v)})
compas_rhino.draw_cylinders(lines, layer="CSD2::thrust", clear=False, redraw=False)
Ex 2. Draw Reactions
# ==============================================================================
# Draw Reactions
# ==============================================================================
scale = 0.01
tol = 0.001
lines = []
for key in thrust.vertices_where({'is_anchor': True}):
reaction = thrust.vertex_attributes(key, ['_rx', '_ry', '_rz'])
reaction = scale_vector(reaction, scale)
if length_vector(reaction) < tol:
continue
sp = thrust.vertex_coordinates(key)
ep = add_vectors(sp, reaction)
lines.append({
'start': sp,
'end': ep,
'color': (255, 0, 0),
'arrow': 'start',
'name': "{}.reaction.{}".format(thrust.name, key)})
compas_rhino.draw_lines(lines, layer="CSD2::thrust", clear=False, redraw=False)
Ex 3. Draw Self-weight
# ==============================================================================
# Draw Self-weight
# ==============================================================================
scale = 0.01
tol = 0.001
lines = []
tol2 = tol ** 2
for key in thrust.vertices_where({'is_anchor': False}):
t = thrust.vertex_attribute(key, 't')
a = thrust.vertex_area(key)
sp = thrust.vertex_coordinates(key)
dz = scale * t * a
if dz ** 2 < tol2:
continue
ep = [sp[0], sp[1], sp[2] - dz]
lines.append({
'start': sp,
'end': ep,
'color': (0, 255, 0),
'arrow': 'end',
'name': "{}.selfweight.{}".format(thrust.name, key)})
compas_rhino.draw_lines(lines, layer="CSD2::thrust", clear=False, redraw=False)
Ex 4: Draw Residuals
# ==============================================================================
# Draw Residuals
# ==============================================================================
scale = 0.01
tol = 0.001
lines = []
for key in thrust.vertices_where({'is_anchor': False}):
residual = thrust.vertex_attributes(key, ['_rx', '_ry', '_rz'])
residual = scale_vector(residual, scale)
if length_vector(residual) < tol:
continue
sp = thrust.vertex_coordinates(key)
ep = add_vectors(sp, residual)
lines.append({
'start': sp,
'end': ep,
'color': (0, 255, 0),
'arrow': 'start',
'name': "{}.residual.{}".format(thrust.name, key)})
compas_rhino.draw_lines(lines, layer="CSD2::thrust", clear=False, redraw=False)
Last updated