|
5 | 5 |
|
6 | 6 | import rhinoscriptsyntax as rs # type: ignore |
7 | 7 |
|
8 | | -from compas_rv.datastructures import FormDiagram |
9 | 8 | from compas_rv.datastructures import ThrustDiagram |
10 | | -from compas_rv.scene import RhinoFormObject |
11 | | -from compas_rv.scene import RhinoThrustObject |
12 | 9 | from compas_rv.session import RVSession |
13 | 10 | from compas_tna.equilibrium import vertical_from_zmax |
14 | 11 |
|
15 | 12 |
|
16 | 13 | def RunCommand(): |
17 | 14 | session = RVSession() |
18 | 15 |
|
19 | | - formobj: RhinoFormObject = session.scene.find_by_itemtype(FormDiagram) |
20 | | - if not formobj: |
| 16 | + form = session.find_formdiagram() |
| 17 | + if not form: |
| 18 | + return |
| 19 | + |
| 20 | + force = session.find_forcediagram() |
| 21 | + if not force: |
| 22 | + return |
| 23 | + |
| 24 | + thrust = session.find_thrustdiagram() |
| 25 | + if not thrust: |
21 | 26 | return |
22 | 27 |
|
23 | 28 | # ============================================================================= |
24 | 29 | # Compute horizontal |
25 | 30 | # ============================================================================= |
26 | 31 |
|
27 | | - kmax = session.settings.tna.vertical.kmax |
28 | | - zmax = session.settings.tna.vertical.zmax |
| 32 | + # density |
| 33 | + kmax = session.settings.tna.vertical_kmax |
| 34 | + zmax = session.settings.tna.vertical_zmax |
29 | 35 | zmax = rs.GetReal("Set maximum height (zmax)", number=zmax, minimum=0) |
30 | 36 |
|
31 | | - # warn the user about nonsensical values |
| 37 | + if zmax is None: |
| 38 | + return |
| 39 | + |
| 40 | + session.settings.tna.vertical_zmax = zmax |
| 41 | + |
| 42 | + # copy the vertical coordinates of the thrust diagram |
| 43 | + # onto the form diagram |
| 44 | + for vertex in thrust.diagram.vertices_where(is_support=True): |
| 45 | + z = thrust.diagram.vertex_attribute(vertex, "z") |
| 46 | + form.diagram.vertex_attribute(vertex, "z", z) |
32 | 47 |
|
33 | | - _, scale = vertical_from_zmax(formobj.mesh, zmax, kmax=kmax) |
| 48 | + # can we not use the thrust diagram here |
| 49 | + _, scale = vertical_from_zmax(form.diagram, zmax, kmax=kmax) |
34 | 50 |
|
35 | 51 | # store scale in force diagram |
| 52 | + print(scale) |
36 | 53 |
|
37 | | - thrust: ThrustDiagram = formobj.mesh.copy(cls=ThrustDiagram) |
38 | | - thrust.name = "ThrustDiagram" |
| 54 | + thrustdiagram: ThrustDiagram = form.diagram.copy(cls=ThrustDiagram) |
| 55 | + thrustdiagram.name = "ThrustDiagram" |
39 | 56 |
|
40 | | - formobj.mesh.vertices_attribute(name="z", value=0) |
| 57 | + # flatten the formdiagram again |
| 58 | + form.diagram.vertices_attribute(name="z", value=0) |
| 59 | + |
| 60 | + # show the thrust diagram |
| 61 | + thrust.show = True |
41 | 62 |
|
42 | 63 | # ============================================================================= |
43 | 64 | # Update scene |
44 | 65 | # ============================================================================= |
45 | 66 |
|
46 | 67 | rs.UnselectAllObjects() |
47 | 68 |
|
48 | | - thrustobj = session.scene.find_by_itemtype(ThrustDiagram) |
49 | | - |
50 | | - if not thrustobj: |
51 | | - thrustobj: RhinoThrustObject = session.scene.add(thrust, name=thrust.name) |
52 | | - else: |
53 | | - thrustobj.mesh = thrust |
54 | | - |
55 | | - thrustobj.clear() |
56 | | - thrustobj.draw() |
57 | | - rs.Redraw() |
58 | | - |
59 | | - # ============================================================================= |
60 | | - # Save session |
61 | | - # ============================================================================= |
| 69 | + thrust.diagram = thrustdiagram |
| 70 | + thrust.redraw() |
62 | 71 |
|
63 | 72 | if session.settings.autosave: |
64 | 73 | session.record(name="TNA Vertical") |
|
0 commit comments