Sorry for duplicating the issue, but I assumed the compas-assembly repo was part of the compas-dev.
*Describe the bug**
The DEM Viewer throws an error when loading an assembly with null forces, with both CRA solvers.
Traceback (most recent call last):
File "d:\10_DEV\CompasWorkshop\mcneel22\RandomWall\02_collectRHgeometry.py", line 88, in <module>
viewer.add_assembly(assembly)
File "C:\Users\Filipe\anaconda3\envs\mcneel22\lib\site-packages\compas_assembly\viewer\app.py", line 224, in add_assembly
resultants += interface.resultantforce
File "C:\Users\Filipe\anaconda3\envs\mcneel22\lib\site-packages\compas_assembly\datastructures\interface.py", line 176, in resultantforce
position = Point(*centroid_points_weighted(self.points, normalcomponents))
File "C:\Users\Filipe\anaconda3\envs\mcneel22\lib\site-packages\compas\geometry\_core\centroids.py", line 163, in centroid_points_weighted
vector = scale_vector(sum_vectors(vectors), 1.0 / sum(weights))
ZeroDivisionError: float division by zero
To Reproduce
Steps to reproduce the behavior:
Creating a block assembly with horizontal interfaces between the blocks in the same row. The sample script assumes a pyramid with 6 bricks.
A sample script that reproduces the error:
import os
import compas
from compas.colors import Color
from compas.geometry import Translation
from compas.datastructures import Mesh
from compas_assembly.datastructures import Block
from compas_assembly.datastructures import Assembly
from compas_assembly.algorithms import assembly_interfaces
#from compas_view2.app import App
from compas_assembly.viewer import DEMViewer
from compas_cra.equilibrium import cra_solve
# =============================================================================
# Import
# =============================================================================
filepath = os.path.join(os.path.dirname(__file__), "test.json")
data = compas.json_load(filepath)
boxes = data["blocks"]
# =============================================================================
# Assembly
# =============================================================================
assembly = Assembly()
for box in boxes:
assembly.add_block_from_mesh(Mesh.from_shape(box))
# =============================================================================
# Identify interfaces
# =============================================================================
# inputs = the assembly, maximum distance and minimum area
assembly_interfaces(assembly, tmax=0.001, amin=1e-4)
# =============================================================================
# Boundary conditions
# =============================================================================
assembly.unset_boundary_conditions()
nodes = sorted(assembly.nodes(), key=lambda node: assembly.node_point(node).z)
for node in nodes[:3]:
assembly.set_boundary_condition(node)
# =============================================================================
# Equilibrium
# =============================================================================
cra_solve(assembly)
# =============================================================================
# Viz
# =============================================================================
viewer = DEMViewer()
viewer.view.camera.position = [0, -5, 5]
viewer.view.camera.look_at([0, 0, 3])
viewer.add_assembly(assembly)
viewer.run()
Sorry for duplicating the issue, but I assumed the compas-assembly repo was part of the compas-dev.
*Describe the bug** The DEM Viewer throws an error when loading an assembly with null forces, with both CRA solvers.
To Reproduce Steps to reproduce the behavior:
A sample script that reproduces the error:
Expected behavior Zero forces should not be displayed
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):