55import rhinoscriptsyntax as rs # type: ignore
66
77from compas_rv .session import RVSession
8- from compas_rv .solvers import InteractiveScaleHorizontal
8+ from compas_rv .solvers import update_force_from_form
9+ from compas_tna .equilibrium import vertical_from_zmax
910
1011
1112def RunCommand ():
@@ -30,9 +31,12 @@ def RunCommand():
3031 # Modify pattern vertices
3132 # =============================================================================
3233
34+ kmax = session .settings .tna .vertical_kmax
35+ zmax = session .settings .tna .vertical_zmax
36+
3337 rs .UnselectAllObjects ()
3438
35- options = ["VertexAttributes" , "EdgeAttributes" , "FaceAttributes" , "MoveSupports" , "ScaleForces " ]
39+ options = ["VertexAttributes" , "EdgeAttributes" , "FaceAttributes" , "MoveSupports" , "ScaleForceDensities " ]
3640 option = rs .GetString ("Modify the Thrust Diagram" , strings = options )
3741 if not option :
3842 return
@@ -60,22 +64,37 @@ def RunCommand():
6064 if selected :
6165 thrust .move_vertices_direction (selected , direction = "Z" )
6266
63- # interactively change the scale of the force diagram
64- # recompute vertical equilibrium accordingly
65- # use vertical_from_q
67+ elif option == "ScaleForceDensities" :
68+ thrust .show_edges = list (thrust .diagram .edges_where (_is_edge = True ))
69+ thrust .redraw_edges ()
70+ selected = thrust .select_edges ()
71+ if selected :
72+ selected = list (set (selected ))
73+ factor = rs .GetReal ("Scale factor" , number = 1.0 , minimum = 0 )
74+ if not factor :
75+ return
76+ for edge in selected :
77+ q = factor * thrust .diagram .edge_attribute (edge , "q" )
78+
79+ form .diagram .edge_attribute (edge , "q" , q )
6680
67- elif option == "ScaleForces" :
68- scalehorizontal = InteractiveScaleHorizontal (thrust .diagram )
69- if scalehorizontal ():
70- force .diagram .attributes ["scale" ] = scalehorizontal .scale
81+ form .diagram .solve_fd ()
82+ update_force_from_form (force .diagram , form .diagram )
83+ _ , scale = vertical_from_zmax (form .diagram , zmax , kmax = kmax )
84+ force .diagram .attributes ["scale" ] = scale
85+ force .diagram .update_position ()
7186
72- for index , vertex in enumerate (thrust .diagram .vertices ()):
73- thrust .diagram .vertex_attribute (vertex , "z" , scalehorizontal .numdata .xyz [index , 2 ]) # type: ignore
87+ for vertex in form .diagram .vertices ():
88+ form_attr = form .diagram .vertex_attributes (vertex )
89+ thrust_attr = thrust .diagram .vertex_attributes (vertex )
90+ thrust_attr .update (form_attr ) # type: ignore
7491
75- for index , edge in enumerate (thrust .diagram .edges_where (_is_edge = True )):
76- q = scalehorizontal .scale * scalehorizontal .numdata .q [index , 0 ] # type: ignore
77- form .diagram .edge_attribute (edge , "q" , q )
78- thrust .diagram .edge_attribute (edge , "q" , q )
92+ for edge in form .diagram .edges ():
93+ form_attr = form .diagram .edge_attributes (edge )
94+ thrust_attr = thrust .diagram .edge_attributes (edge )
95+ thrust_attr .update (form_attr ) # type: ignore
96+
97+ form .diagram .vertices_attribute (name = "z" , value = 0 )
7998
8099 else :
81100 raise NotImplementedError
@@ -90,15 +109,24 @@ def RunCommand():
90109 rs .UnselectAllObjects ()
91110
92111 form .show_vertices = True
93- form .redraw_vertices ()
112+ form .show_free = False
113+ form .show_fixed = True
114+ form .show_supports = True
115+ form .show_edges = True
116+
117+ force .show_vertices = True
118+ force .show_free = False
119+ force .show_fixed = True
120+ force .show_supports = True
121+ force .show_edges = True
94122
95123 thrust .show_vertices = True # type: ignore
96124 thrust .show_free = False
97125 thrust .show_fixed = True
98126 thrust .show_supports = True
99127 thrust .show_edges = False
100128
101- thrust .redraw ()
129+ session . scene .redraw ()
102130
103131 if session .settings .autosave :
104132 session .record (name = "Modify Thrust Diagram" )
0 commit comments