|
2 | 2 | # venv: brg-csd |
3 | 3 | # r: compas_fofin>=0.15.2 |
4 | 4 |
|
5 | | -import rhinoscriptsyntax as rs # type: ignore |
| 5 | +import pathlib |
6 | 6 |
|
| 7 | +# import rhinoscriptsyntax as rs # type: ignore |
7 | 8 | import compas |
| 9 | +from compas.datastructures import Mesh |
8 | 10 | from compas_fofin.scene import RhinoCableMeshObject |
9 | 11 | from compas_fofin.session import FoFinSession |
10 | 12 | from compas_rui.forms import FileForm |
|
13 | 15 | def RunCommand(): |
14 | 16 | session = FoFinSession() |
15 | 17 |
|
16 | | - meshobj: RhinoCableMeshObject = session.scene.find_by_name(name="CableMesh") |
17 | | - |
18 | | - options = ["Scene", "CableMesh"] |
19 | | - option = rs.GetString(message="Export", strings=options) |
20 | | - if not option: |
| 18 | + meshobj: RhinoCableMeshObject = session.find_cablemesh() |
| 19 | + if not meshobj: |
21 | 20 | return |
22 | 21 |
|
23 | | - if option == "Scene": |
24 | | - filepath = FileForm.save(session.basedir, "FormFinder-scene.json") |
25 | | - if not filepath: |
26 | | - return |
| 22 | + # options = ["Scene", "CableMesh"] |
| 23 | + # option = rs.GetString(message="Export", strings=options) |
| 24 | + # if not option: |
| 25 | + # return |
| 26 | + |
| 27 | + # if option == "Scene": |
| 28 | + # filepath = FileForm.save(session.basedir, "FormFinder-Scene.json") |
| 29 | + # if not filepath: |
| 30 | + # return |
| 31 | + |
| 32 | + # compas.json_dump(session.scene, filepath) |
27 | 33 |
|
28 | | - compas.json_dump(session.scene, filepath) |
| 34 | + # elif option == "CableMesh": |
29 | 35 |
|
30 | | - elif option == "CableMesh": |
31 | | - filepath = FileForm.save(session.basedir, "FormFinder-cablemesh.json") |
32 | | - if not filepath: |
33 | | - return |
| 36 | + mesh: Mesh = meshobj.mesh.copy() |
| 37 | + for face in list(mesh.faces_where(_is_loaded=False)): |
| 38 | + mesh.delete_face(face) |
| 39 | + |
| 40 | + basedir = session.basedir or pathlib.Path().home() |
| 41 | + basename = "FormFinder-Cablemesh.json" |
| 42 | + filepath = FileForm.save(str(basedir), basename) |
| 43 | + if not filepath: |
| 44 | + return |
34 | 45 |
|
35 | | - compas.json_dump(meshobj.mesh, filepath) |
| 46 | + compas.json_dump(mesh, filepath) |
36 | 47 |
|
37 | 48 |
|
38 | 49 | # ============================================================================= |
|
0 commit comments