IanYeo commited on
Commit
b3fcda8
·
1 Parent(s): 8e5681d

working changes

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -101,7 +101,9 @@ def updateZipForMultipleFiles(file_names_and_data, zipname='temp.zip'):
101
  # now add filename with its new data
102
  for individual_update in file_names_and_data:
103
  with zipfile.ZipFile(zipname, mode='a', compression=zipfile.ZIP_DEFLATED) as zf:
104
- zf.writestr(individual_update['individual_file'], individual_update['xml_string_update'])
 
 
105
 
106
 
107
  def updateZValue(xml_data, xml_element_to_iterate, z_error_correction_in_metres):
@@ -120,15 +122,10 @@ st.markdown(
120
  '''
121
  # Adjust the height of all issues in a BCF file
122
 
123
- Provide any spreadsheet (using a dropbox link) that has a column of revit IDs.
124
- A typical Revit ID is `60f91daf-3dd7-4283-a86d-24137b73f3da-0001fd0b`.
125
- This app will convert the ID to `3CPy6r22DAahSW8AIIobik`.
126
-
127
-
128
- Select the sheet witin the spreadsheet and the column with the IDs.
129
 
 
130
 
131
- Only the selected sheet will be returned, you can cut and paste the sheet back into the origial spreadsheet.
132
  '''
133
  )
134
 
@@ -152,11 +149,11 @@ if bcf_file_button:
152
 
153
  if '.bcf' in bcf_file_path:
154
 
 
155
  partial_filename = bcf_file_path.rsplit('/')[-1]
156
  filename = partial_filename.split('.bcf')[0]
157
  bcf_file_path = bcf_file_path.replace('.bcf', '.zip')
158
 
159
-
160
  r = requests.get(bcf_file_path, stream=True)
161
  if r.status_code == 200:
162
  with open(path_original, 'wb') as f:
@@ -168,8 +165,8 @@ if bcf_file_button:
168
 
169
  height_change_button = st.number_input(
170
  "Height of the sheet to be returned",
171
- # value=float,
172
  format="%.3f",
 
173
  min_value=-1000.0,
174
  max_value=1000.0,
175
  step=0.001,
@@ -185,17 +182,19 @@ if bcf_file_button:
185
  height_change,
186
  )
187
 
188
- updateZipForMultipleFiles(
189
  update_bcf_info,
190
  )
191
 
192
- with open(path_updated, "rb") as fp:
193
- btn = st.download_button(
194
- label="Download BCF file",
195
- data=fp,
196
- file_name=f"{filename}_height_{height_change}.bcf",
197
- mime="application/zip"
198
- )
 
 
199
 
200
  else:
201
 
 
101
  # now add filename with its new data
102
  for individual_update in file_names_and_data:
103
  with zipfile.ZipFile(zipname, mode='a', compression=zipfile.ZIP_DEFLATED) as zf:
104
+ zf.writestr(individual_update['individual_file'], individual_update['xml_string_update'])
105
+
106
+ return True
107
 
108
 
109
  def updateZValue(xml_data, xml_element_to_iterate, z_error_correction_in_metres):
 
122
  '''
123
  # Adjust the height of all issues in a BCF file
124
 
125
+ Provide any bcf file.
 
 
 
 
 
126
 
127
+ Select the height adjustment in metres.
128
 
 
129
  '''
130
  )
131
 
 
149
 
150
  if '.bcf' in bcf_file_path:
151
 
152
+ updated = False
153
  partial_filename = bcf_file_path.rsplit('/')[-1]
154
  filename = partial_filename.split('.bcf')[0]
155
  bcf_file_path = bcf_file_path.replace('.bcf', '.zip')
156
 
 
157
  r = requests.get(bcf_file_path, stream=True)
158
  if r.status_code == 200:
159
  with open(path_original, 'wb') as f:
 
165
 
166
  height_change_button = st.number_input(
167
  "Height of the sheet to be returned",
 
168
  format="%.3f",
169
+ value=0.000,
170
  min_value=-1000.0,
171
  max_value=1000.0,
172
  step=0.001,
 
182
  height_change,
183
  )
184
 
185
+ updated = updateZipForMultipleFiles(
186
  update_bcf_info,
187
  )
188
 
189
+ if updated:
190
+
191
+ with open(path_updated, "rb") as fp:
192
+ btn = st.download_button(
193
+ label="Download BCF file",
194
+ data=fp,
195
+ file_name=f"{filename}_height_{height_change}.bcf",
196
+ mime="application/zip"
197
+ )
198
 
199
  else:
200