Skip to content

Commit 1d2d8df

Browse files
committed
add blocks command
1 parent 270ac1b commit 1d2d8df

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

commands/RV_dem_blocks.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#! python3
2+
# venv: brg-csd
3+
# r: compas_rv>=0.9.1
4+
5+
import rhinoscriptsyntax as rs # type: ignore
6+
from compas_dem.models import BlockModel
7+
8+
from compas.datastructures import Mesh
9+
from compas_rv.session import RVSession
10+
11+
12+
def RunCommand():
13+
session = RVSession()
14+
15+
thrust = session.find_thrustdiagram()
16+
if not thrust:
17+
print("There is no ThrustDiagram in the scene.")
18+
return
19+
20+
option = rs.GetString(message="DEM Blocks From", strings=["Dual", "MeshPattern"])
21+
22+
if option == "Dual":
23+
mesh: Mesh = thrust.diagram.copy()
24+
for face in list(mesh.faces_where(_is_loaded=False)):
25+
mesh.delete_face(face)
26+
model = BlockModel.from_meshdual(mesh)
27+
28+
elif option == "MeshPattern":
29+
raise NotImplementedError
30+
31+
else:
32+
raise NotImplementedError
33+
34+
# =============================================================================
35+
# Scene
36+
# =============================================================================
37+
38+
for block in model.blocks():
39+
session.scene.add(block.modelgeometry)
40+
41+
session.scene.redraw()
42+
43+
# =============================================================================
44+
# Autosave
45+
# =============================================================================
46+
47+
if session.settings.autosave:
48+
session.record(name="Create BlockModel")
49+
50+
51+
# =============================================================================
52+
# Run as main
53+
# =============================================================================
54+
55+
if __name__ == "__main__":
56+
RunCommand()

compas-RV.rhproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"id": "a6dc4669-0e8e-40ea-8d71-b9b0f4764ec1",
99
"identity": {
1010
"name": "COMPAS-RhinoVAULT",
11-
"version": "0.6.27",
11+
"version": "0.6.30",
1212
"publisher": {
1313
"email": "[email protected]",
1414
"name": "Tom Van Mele",
@@ -627,6 +627,15 @@
627627
},
628628
"title": "RV_thrust_info",
629629
"uri": "commands/RV_thrust_info.py"
630+
},
631+
{
632+
"id": "b4188b27-d157-4b8c-bd8e-7f8543ccaa93",
633+
"language": {
634+
"id": "*.*.python",
635+
"version": "3.*.*"
636+
},
637+
"title": "RV_dem_blocks",
638+
"uri": "commands/RV_dem_blocks.py"
630639
}
631640
],
632641
"resources": [

0 commit comments

Comments
 (0)