55import rhinoscriptsyntax as rs # type: ignore
66
77from compas_masonry .session import MasonrySession as Session
8+ from compas_rui import feedback
89from compas_tna .envelope import CrossVaultEnvelope
910from compas_tna .envelope import DomeEnvelope
1011from compas_tna .envelope import Envelope
12+ from compas_tna .envelope import PavillionVaultEnvelope
13+ from compas_tna .envelope import PointedVaultEnvelope
1114
1215
1316def RunCommand ():
1417 session = Session ()
1518
16- envelopeobject = session .scene .find_by_itemtype (Envelope )
17- if envelopeobject :
18- envelopeobject .clear ()
19- session .scene .remove (envelopeobject )
19+ formdiagram = session ["formdiagram" ]
20+
21+ if not formdiagram :
22+ feedback .warn ("There is no FormDiagram. Please create one first." )
23+ return
2024
2125 session .delete ("envelope" )
2226
27+ obj = session .scene .find_by_itemtype (Envelope )
28+ if obj :
29+ obj .clear ()
30+ session .scene .remove (obj )
31+
2332 # =============================================================================
2433 # Create an envelope
2534 # =============================================================================
2635
2736 envelope = None
2837
29- option = rs .GetString (message = "Create an envelope " , strings = ["FormDiagram " , "Middle " , "Intrados " , "BoundsMeshes " ])
38+ option = rs .GetString (message = "Envelope " , strings = ["FromLibrary " , "FromMiddle " , "FromIntrados " , "FromBounds " ])
3039 if not option :
3140 return
3241
33- if option == "FormDiagram" :
42+ if option == "FromLibrary" :
43+ option = rs .GetString (message = "Choose a pattern" , strings = ["CrossVault" , "PointedVault" , "PavilionVault" , "Dome" ])
44+ if not option :
45+ return
46+
47+ # =============================================================================
48+ # CrossVault
49+ # =============================================================================
50+
51+ if option == "CrossVault" :
52+ x_span = session ["params" ]["x_span" ]
53+ y_span = session ["params" ]["y_span" ]
54+ n = session ["params" ]["n" ]
55+
56+ thickness = rs .GetReal ("Thickness" , 0.5 , 0.0 , 100 )
57+ if not thickness :
58+ return
59+
60+ envelope = CrossVaultEnvelope (
61+ x_span = x_span ,
62+ y_span = y_span ,
63+ thickness = thickness ,
64+ n = n ,
65+ )
66+
67+ # =============================================================================
68+ # PointedVault
69+ # =============================================================================
70+
71+ elif option == "PointedVault" :
72+ pass
73+
74+ # =============================================================================
75+ # PavilionVault
76+ # =============================================================================
77+
78+ elif option == "PavilionVault" :
79+ pass
80+
3481 # =============================================================================
3582 # Dome
3683 # =============================================================================
3784
38- if session [ "params" ][ "formdiagram" ] == "circular " :
85+ elif option == "Dome " :
3986 center = session ["params" ]["center" ]
4087 radius = session ["params" ]["radius" ]
4188 n_hoops = session ["params" ]["n_hoops" ]
@@ -55,26 +102,6 @@ def RunCommand():
55102 r_oculus = r_oculus ,
56103 )
57104
58- # =============================================================================
59- # Cross
60- # =============================================================================
61-
62- elif session ["params" ]["formdiagram" ] == "cross" :
63- x_span = session ["params" ]["x_span" ]
64- y_span = session ["params" ]["y_span" ]
65- n = session ["params" ]["n" ]
66-
67- thickness = rs .GetReal ("Thickness" , 0.5 , 0.0 , 100 )
68- if not thickness :
69- return
70-
71- envelope = CrossVaultEnvelope (
72- x_span = x_span ,
73- y_span = y_span ,
74- thickness = thickness ,
75- n = n ,
76- )
77-
78105 # =============================================================================
79106 # Not supported
80107 # =============================================================================
@@ -86,7 +113,7 @@ def RunCommand():
86113 # Middle
87114 # =============================================================================
88115
89- elif option == "Middle " :
116+ elif option == "FromMiddle " :
90117 # select the middle surface mesh
91118 # specify the thickness
92119 # compute the envelope
@@ -96,7 +123,7 @@ def RunCommand():
96123 # Intrados
97124 # =============================================================================
98125
99- elif option == "Intrados " :
126+ elif option == "FromIntrados " :
100127 # select the intrados mesh
101128 # specify the thickness
102129 # compute the envelope
@@ -106,7 +133,7 @@ def RunCommand():
106133 # BoundsMeshes
107134 # =============================================================================
108135
109- elif option == "BoundsMeshes " :
136+ elif option == "FromBounds " :
110137 # select the intrados mesh
111138 # select the extrados mesh
112139 # compute the envelope
@@ -128,6 +155,7 @@ def RunCommand():
128155 if not envelope :
129156 return
130157
158+ envelope .apply_bounds_to_formdiagram (formdiagram )
131159 session ["envelope" ] = envelope
132160
133161 show_intrados = session .settings .envelope .show_intrados
0 commit comments