IanYeo commited on
Commit
b3892b9
1 Parent(s): 4f47930
Files changed (1) hide show
  1. app.py +33 -14
app.py CHANGED
@@ -25,6 +25,21 @@ def compress(g):
25
 
26
  return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  def download_button(object_to_download, download_filename, button_text, pickle_it=False):
30
  """
@@ -123,7 +138,7 @@ st.markdown(
123
 
124
  Select the sheet witin the spreadsheet and the column with the IDs.
125
 
126
-
127
  Only the selected sheet will be returned, you can cut and paste the sheet back into the origial spreadsheet.
128
  '''
129
  )
@@ -145,6 +160,7 @@ if cobie_file_button:
145
  tabs = cobie_file.sheet_names
146
 
147
  selected_column = None
 
148
 
149
  if tabs:
150
  selected_sheet = st.selectbox(
@@ -165,20 +181,23 @@ if tabs:
165
 
166
  if selected_column:
167
 
168
- # df['COBieGUID'] = df[selected_column].apply(compress)
169
-
170
- st.write(df)
 
 
 
171
 
172
- # st.markdown(
173
- # download_button(
174
- # df,
175
- # 'COBieGUIDs.xlsx',
176
- # 'Download COBieGUIDs.xlsx',
177
- # pickle_it=False,
178
- # ),
179
- # unsafe_allow_html=True,
180
- # )
181
- # st.markdown(download_button(df, 'COBieIDs.xlsx', 'Download COBieIDs.xlsx'), unsafe_allow_html=True)
182
 
183
 
184
 
 
25
 
26
  return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
27
 
28
+ def revit_id_to_guid(sheet, column):
29
+
30
+ id_components = sheet[column].rsplit('-', 1)
31
+ episode_id = id_components[0]
32
+ element_id = id_components[1]
33
+ revit_end_start = episode_id.rsplit('-', 1)
34
+ episode_id_base10 = int(element_id, 16)
35
+ revit_end_base10 = int(revit_end_start[1], 16)
36
+ base10_components = episode_id_base10 ^ revit_end_base10
37
+ guid = revit_end_start[0] + '-' + hex(base10_components)[2:]
38
+
39
+ return compress(uuid.UUID(guid).hex)
40
+
41
+
42
+
43
 
44
  def download_button(object_to_download, download_filename, button_text, pickle_it=False):
45
  """
 
138
 
139
  Select the sheet witin the spreadsheet and the column with the IDs.
140
 
141
+
142
  Only the selected sheet will be returned, you can cut and paste the sheet back into the origial spreadsheet.
143
  '''
144
  )
 
160
  tabs = cobie_file.sheet_names
161
 
162
  selected_column = None
163
+ df = pd.DataFrame
164
 
165
  if tabs:
166
  selected_sheet = st.selectbox(
 
181
 
182
  if selected_column:
183
 
184
+ # df['COBieGUID'] = df.apply(compress)
185
+ df[selected_column] = df.apply(
186
+ revit_id_to_guid,
187
+ column_name=selected_column,
188
+ axis=1
189
+ )
190
 
191
+ st.markdown(
192
+ download_button(
193
+ df,
194
+ 'IFC_GUIDs.xlsx',
195
+ 'Download IFC GUIDs sheet',
196
+ pickle_it=False,
197
+ ),
198
+ unsafe_allow_html=True,
199
+ )
200
+ st.markdown(download_button(df, 'COBieIDs.xlsx', 'Download COBieIDs.xlsx'), unsafe_allow_html=True)
201
 
202
 
203