IanYeo commited on
Commit
89cf0d5
1 Parent(s): 2c4eec1

app working locally

Browse files
Files changed (1) hide show
  1. app.py +38 -31
app.py CHANGED
@@ -14,7 +14,6 @@ import streamlit as st
14
 
15
 
16
  chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + '_$'
17
- selected_sheet = None
18
  tabs = None
19
 
20
  def compress(g):
@@ -40,10 +39,15 @@ def revit_id_to_guid(sheet = pd.DataFrame, column = string):
40
  base10_components = episode_id_base10 ^ revit_end_base10
41
  guid = revit_end_start[0] + '-' + hex(base10_components)[2:]
42
 
43
- return compress(uuid.UUID(guid).hex)
44
-
45
 
 
46
 
 
 
 
 
47
 
48
  def download_button(object_to_download, download_filename, button_text, pickle_it=False):
49
  """
@@ -138,8 +142,8 @@ st.markdown(
138
  # Convert Revit IDs to GUIDs
139
 
140
  Provide any spreadsheet (using a dropbox link) that has a column of revit IDs.
141
- A typical Revit IDS is `60f91daf-3dd7-4283-a86d-24137b73f3da-0001fd0b`.
142
- The script will convert the ID to `3CPy6r22DAahSW8AIIobik`.
143
 
144
 
145
  Select the sheet witin the spreadsheet and the column with the IDs.
@@ -168,6 +172,8 @@ if cobie_file_button:
168
  df = pd.DataFrame()
169
 
170
  if tabs:
 
 
171
  selected_sheet = st.selectbox(
172
  'Select sheet for changing revit ids to COBie ids',
173
  tabs,
@@ -177,35 +183,36 @@ if tabs:
177
 
178
  df = cobie_file.parse(selected_sheet)
179
 
180
- if type(df) == pd.DataFrame:
181
 
182
- # st.write(df)
183
- selected_column = None
184
- columns = df.columns
185
- selected_column = st.selectbox(
186
- 'Select column with revit ids',
187
- columns,
 
 
 
 
 
 
 
 
 
 
 
188
  )
189
 
190
- if selected_column:
191
-
192
- # df['COBieGUID'] = df.apply(compress)
193
- df[selected_column] = df.apply(
194
- revit_id_to_guid,
195
- column=selected_column,
196
- axis=1
197
- )
198
-
199
- st.markdown(
200
- download_button(
201
- df,
202
- 'IFC_GUIDs.xlsx',
203
- 'Download IFC GUIDs sheet',
204
- pickle_it=False,
205
- ),
206
- unsafe_allow_html=True,
207
- )
208
- st.markdown(download_button(df, 'COBieIDs.xlsx', 'Download COBieIDs.xlsx'), unsafe_allow_html=True)
209
 
210
 
211
 
 
14
 
15
 
16
  chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + '_$'
 
17
  tabs = None
18
 
19
  def compress(g):
 
39
  base10_components = episode_id_base10 ^ revit_end_base10
40
  guid = revit_end_start[0] + '-' + hex(base10_components)[2:]
41
 
42
+ try:
43
+ guid = compress(uuid.UUID(guid).hex)
44
 
45
+ except ValueError:
46
 
47
+ guid = sheet[column]
48
+
49
+ return guid
50
+
51
 
52
  def download_button(object_to_download, download_filename, button_text, pickle_it=False):
53
  """
 
142
  # Convert Revit IDs to GUIDs
143
 
144
  Provide any spreadsheet (using a dropbox link) that has a column of revit IDs.
145
+ A typical Revit ID is `60f91daf-3dd7-4283-a86d-24137b73f3da-0001fd0b`.
146
+ This app will convert the ID to `3CPy6r22DAahSW8AIIobik`.
147
 
148
 
149
  Select the sheet witin the spreadsheet and the column with the IDs.
 
172
  df = pd.DataFrame()
173
 
174
  if tabs:
175
+
176
+ selected_sheet = None
177
  selected_sheet = st.selectbox(
178
  'Select sheet for changing revit ids to COBie ids',
179
  tabs,
 
183
 
184
  df = cobie_file.parse(selected_sheet)
185
 
186
+ if type(df) == pd.DataFrame:
187
 
188
+ # st.write(df)
189
+ selected_column = None
190
+ columns = df.columns
191
+ selected_column = st.selectbox(
192
+ 'Select column with revit ids',
193
+ columns,
194
+ )
195
+
196
+ convert = st.button(f"Sheet = '{selected_sheet}' Column = '{selected_column}' Convert IDs to COBie IDs")
197
+
198
+ if convert:
199
+
200
+ # df['COBieGUID'] = df.apply(compress)
201
+ df[selected_column] = df.apply(
202
+ revit_id_to_guid,
203
+ column=selected_column,
204
+ axis=1
205
  )
206
 
207
+ st.markdown(
208
+ download_button(
209
+ df,
210
+ 'IFC_GUIDs.xlsx',
211
+ 'Download sheet with IFC GUIDs',
212
+ pickle_it=False,
213
+ ),
214
+ unsafe_allow_html=True,
215
+ )
 
 
 
 
 
 
 
 
 
 
216
 
217
 
218