22# venv: rhinovault
33# r: compas>=2.5, compas_rui>=0.3.1, compas_session>=0.4.1, compas_tna>=0.5
44
5-
65import rhinoscriptsyntax as rs # type: ignore
76
8- from compas_rv .datastructures import ForceDiagram
9- from compas_rv .scene import RhinoForceObject
107from compas_rv .session import RVSession
118
129
1310def RunCommand ():
1411 session = RVSession ()
1512
16- force : RhinoForceObject = session .scene .find_by_itemtype (ForceDiagram )
13+ form = session .find_formdiagram ()
14+ if not form :
15+ return
16+
17+ force = session .find_forcediagram ()
1718 if not force :
1819 return
1920
2021 # =============================================================================
21- # Modify pattern vertices
22+ # Modify force vertices
2223 # =============================================================================
2324
2425 rs .UnselectAllObjects ()
2526
26- options = ["VertexAttributes" , "EdgeAttributes" ]
27+ options = ["VertexAttributes" , "EdgeAttributes" , "MoveVertices" ]
2728 option = rs .GetString ("Modify the Force Diagram" , strings = options )
29+
2830 if not option :
2931 return
3032
3133 if option == "VertexAttributes" :
32- selectable = list (force .mesh .vertices ())
33- selected = force .select_vertices (selectable )
34+ force .show_vertices = list (force .diagram .vertices ())
35+ force .redraw_vertices ()
36+
37+ selected = force .select_vertices ()
38+
3439 if selected :
3540 force .update_vertex_attributes (selected )
3641
3742 elif option == "EdgeAttributes" :
38- selectable = list (force .mesh .edges_where (_is_edge = True ))
39- selected = force .select_edges (selectable )
43+ force .show_edges = list (force .diagram .edges ())
44+ force .redraw_edges ()
45+
46+ selected = force .select_edges ()
47+
4048 if selected :
4149 force .update_edge_attributes (selected )
4250
51+ elif option == "MoveVertices" :
52+ force .show_vertices = list (force .diagram .vertices ())
53+ force .redraw_vertices ()
54+
55+ selected = force .select_vertices ()
56+
57+ if not selected :
58+ return
59+
60+ directions = ["X" , "Y" , "XY" , "Free" ]
61+ direction = rs .GetString (message = "" , strings = directions )
62+
63+ if not direction :
64+ return
65+
66+ if direction in ("X" , "Y" , "XY" ):
67+ force .move_vertices_direction (selected , direction = direction )
68+
69+ else :
70+ force .move_vertices (selected )
71+
72+ # update angle deviations
73+
4374 else :
4475 raise NotImplementedError
4576
77+ if session .settings .autoupdate :
78+ rs .MessageBox ("Automatic equilibrium updates are not available yet." , title = "Info" )
79+
4680 # =============================================================================
4781 # Update scene
4882 # =============================================================================
@@ -54,14 +88,8 @@ def RunCommand():
5488 force .show_fixed = True
5589 force .show_supports = True
5690 force .show_edges = True
57- force .clear ()
58- force .draw ()
59-
60- rs .Redraw ()
6191
62- # =============================================================================
63- # Save session
64- # =============================================================================
92+ force .redraw ()
6593
6694 if session .settings .autosave :
6795 session .record (name = "Modify Force Diagram" )
0 commit comments