|
| 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() |
0 commit comments