BlockResearchGroup / compas_cra

Coupled Rigid-Block Analysis: Stability-Aware Design of Complex Discrete-Element Assemblies
https://blockresearchgroup.github.io/compas_cra
MIT License
21 stars 7 forks source link

Rhino export #1

Closed daariioo closed 1 year ago

daariioo commented 1 year ago

Hi,

I'm trying to export a simple two block model out of Rhino. For exporting the geometry, I stick to the tutorial provided on the documentation site. When continuing in VS Code, I still continue as shown in the tutorial, as you can see below. When I try to solve the assembly using cra_solve, the following error occured: "IndexError: index(71) out of range". Does someone know why I run into this error? Below you can find my VS Code and attached there are .txt files (.json not supported to upload) of the two blocks (test10 in pretty and test11 in normal).

Thanks in advance and best, Dario

import os import compas import compas_cra

from compas_cra.datastructures import CRA_Assembly from compas_cra.algorithms import assembly_interfaces_numpy from compas_cra.equilibrium import cra_solve from compas_cra.viewers import cra_view

FILE_I = os.path.join(compas_cra.DATA, "test11.json") assembly = compas.json_load(FILE_I) assembly = assembly.copy(cls=CRA_Assembly)

assembly.set_boundary_conditions([0])

assembly_interfaces_numpy(assembly)

cra_solve(assembly, verbose=True, timer=True)

cra_view(assembly, resultant=False, nodal=True, grid=True)

test10.txt test11.txt

GeneKao commented 1 year ago

It seems that your JSON file has some problems. Can you share more details on how you created it? Did you use this script?

daariioo commented 1 year ago

Yes, I did use this script. The obtained .json files are already attached as .txt files (GitHub didn't allow me to upload .json files). test10 is the one in pretty, test11 the normal one.

GeneKao commented 1 year ago

I still can't reproduce your problem.

Can you provide more detail about your:

daariioo commented 1 year ago

My code environment looks as follows:

For exporting the file, I first construct the two blocks in Rhino. Then I create a mesh using the polygon mesh command in Rhino. With the provided script, I select the meshes and export them to the .json file.

Thanks for helping me, and please let me know when you need more information.

GeneKao commented 1 year ago

Can you also provide your Rhino file?

daariioo commented 1 year ago

Of course, here it is:


import compas
import rhinoscriptsyntax as rs

from compas_rhino import select_meshes
from compas_cra.datastructures import CRA_Assembly

HERE = os.path.abspath(os.path.dirname(__file__))
PATH = os.path.abspath(os.path.join(HERE, "..", "data")) 

guid = select_meshes()

assembly = CRA_Assembly()
assembly.add_blocks_from_rhinomeshes(guid)

filename = rs.GetString("file name (xxx.json):")
file_o = os.path.join(PATH, filename)
compas.json_dump(assembly, file_o,pretty=True)
print("file save to: ", file_o)
GeneKao commented 1 year ago

Oh, I meant the rhino .3dm file so I can try the geometry you created. 😃

daariioo commented 1 year ago

Oh, sorry! In the meanwhile, I've tried out different approaches without any success. Therefore, the Blocks could have moved a little, but the file itself is the same. CRA_Rhino_Test.zip

GeneKao commented 1 year ago

The mesh geometry in your Rhino file is not clean, so that's why it didn't work. To make it work for the current implementation, two things in your model need to be fixed:

  1. You will need to select all mesh geometry and use WeldVertices to make sure there are no duplicated vertices (The mesh must be closed mesh, and all vertices are merged for the solver to solve it.)
Screenshot 2023-05-30 at 23 23 15
  1. Try to reduce the mesh faces and have clean input meshes whenever possible, especially on those that overlap. This will make the computation faster and cleaner. The interface detection script doesn't group sub-interfaces. Ideally, those planar contact should have a clean interface like this example.

Additionally, in the current implementation, it's better to make the model smaller and closer to the original to have a better solver's solvability. (Similar scale to those in the CRA examples)

daariioo commented 1 year ago

Thanks a lot for helping! The simple model works now, and I can start testing more complicated stuff. :)