Spaces:
Paused
Paused
Update Doors_Schedule.py
Browse files- Doors_Schedule.py +81 -6
Doors_Schedule.py
CHANGED
|
@@ -1012,7 +1012,7 @@ def add_bluebeam_count_annotations_secondary(pdf_bytes, locations, main_info, se
|
|
| 1012 |
page = pdf_document[0] # First page
|
| 1013 |
if len(main_info) == 2 and len(secondary_info) == 1:
|
| 1014 |
for loc in locations:
|
| 1015 |
-
coor, lbl,
|
| 1016 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1017 |
for cor in coor:
|
| 1018 |
#Create a Circle annotation (Count Markup)
|
|
@@ -1033,7 +1033,7 @@ def add_bluebeam_count_annotations_secondary(pdf_bytes, locations, main_info, se
|
|
| 1033 |
|
| 1034 |
if len(main_info) == 2 and len(secondary_info) == 2:
|
| 1035 |
for loc in locations:
|
| 1036 |
-
coor, lbl,
|
| 1037 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1038 |
for cor in coor:
|
| 1039 |
#Create a Circle annotation (Count Markup)
|
|
@@ -1054,7 +1054,7 @@ def add_bluebeam_count_annotations_secondary(pdf_bytes, locations, main_info, se
|
|
| 1054 |
|
| 1055 |
if len(main_info) == 3 and len(secondary_info) == 1:
|
| 1056 |
for loc in locations:
|
| 1057 |
-
coor, lbl, w,
|
| 1058 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1059 |
for cor in coor:
|
| 1060 |
#Create a Circle annotation (Count Markup)
|
|
@@ -1075,7 +1075,7 @@ def add_bluebeam_count_annotations_secondary(pdf_bytes, locations, main_info, se
|
|
| 1075 |
|
| 1076 |
if len(main_info) == 3 and len(secondary_info) == 2:
|
| 1077 |
for loc in locations:
|
| 1078 |
-
coor, lbl, w,
|
| 1079 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1080 |
for cor in coor:
|
| 1081 |
#Create a Circle annotation (Count Markup)
|
|
@@ -1117,7 +1117,7 @@ def add_bluebeam_count_annotations_secondary(pdf_bytes, locations, main_info, se
|
|
| 1117 |
|
| 1118 |
if len(main_info) == 4 and len(secondary_info) == 2:
|
| 1119 |
for loc in locations:
|
| 1120 |
-
coor, lbl, w, h,
|
| 1121 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1122 |
for cor in coor:
|
| 1123 |
#Create a Circle annotation (Count Markup)
|
|
@@ -1199,7 +1199,7 @@ import PyPDF2
|
|
| 1199 |
import io
|
| 1200 |
from PyPDF2.generic import TextStringObject # ✅ Required for setting string values
|
| 1201 |
|
| 1202 |
-
def add_bluebeam_count_annotations(pdf_bytes, locations):
|
| 1203 |
pdf_stream = io.BytesIO(pdf_bytes) # Load PDF from bytes
|
| 1204 |
pdf_document = fitz.open("pdf", pdf_stream.read()) # Open PDF in memory
|
| 1205 |
|
|
@@ -1271,6 +1271,81 @@ def add_bluebeam_count_annotations(pdf_bytes, locations):
|
|
| 1271 |
pdf_document.close()
|
| 1272 |
|
| 1273 |
return output_stream.getvalue() # Return the modified PDF as bytes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1274 |
|
| 1275 |
|
| 1276 |
def get_user_input(user_words):
|
|
|
|
| 1012 |
page = pdf_document[0] # First page
|
| 1013 |
if len(main_info) == 2 and len(secondary_info) == 1:
|
| 1014 |
for loc in locations:
|
| 1015 |
+
coor, lbl, acous, clr = loc
|
| 1016 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1017 |
for cor in coor:
|
| 1018 |
#Create a Circle annotation (Count Markup)
|
|
|
|
| 1033 |
|
| 1034 |
if len(main_info) == 2 and len(secondary_info) == 2:
|
| 1035 |
for loc in locations:
|
| 1036 |
+
coor, lbl, acous, fire, clr = loc
|
| 1037 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1038 |
for cor in coor:
|
| 1039 |
#Create a Circle annotation (Count Markup)
|
|
|
|
| 1054 |
|
| 1055 |
if len(main_info) == 3 and len(secondary_info) == 1:
|
| 1056 |
for loc in locations:
|
| 1057 |
+
coor, lbl, w, acous, clr = loc
|
| 1058 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1059 |
for cor in coor:
|
| 1060 |
#Create a Circle annotation (Count Markup)
|
|
|
|
| 1075 |
|
| 1076 |
if len(main_info) == 3 and len(secondary_info) == 2:
|
| 1077 |
for loc in locations:
|
| 1078 |
+
coor, lbl, w, acous, fire, clr = loc
|
| 1079 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1080 |
for cor in coor:
|
| 1081 |
#Create a Circle annotation (Count Markup)
|
|
|
|
| 1117 |
|
| 1118 |
if len(main_info) == 4 and len(secondary_info) == 2:
|
| 1119 |
for loc in locations:
|
| 1120 |
+
coor, lbl, w, h, acous, fire, clr = loc
|
| 1121 |
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1122 |
for cor in coor:
|
| 1123 |
#Create a Circle annotation (Count Markup)
|
|
|
|
| 1199 |
import io
|
| 1200 |
from PyPDF2.generic import TextStringObject # ✅ Required for setting string values
|
| 1201 |
|
| 1202 |
+
'''def add_bluebeam_count_annotations(pdf_bytes, locations):
|
| 1203 |
pdf_stream = io.BytesIO(pdf_bytes) # Load PDF from bytes
|
| 1204 |
pdf_document = fitz.open("pdf", pdf_stream.read()) # Open PDF in memory
|
| 1205 |
|
|
|
|
| 1271 |
pdf_document.close()
|
| 1272 |
|
| 1273 |
return output_stream.getvalue() # Return the modified PDF as bytes
|
| 1274 |
+
'''
|
| 1275 |
+
def add_bluebeam_count_annotations(pdf_bytes, locations):
|
| 1276 |
+
pdf_stream = io.BytesIO(pdf_bytes) # Load PDF from bytes
|
| 1277 |
+
pdf_document = fitz.open("pdf", pdf_stream.read()) # Open PDF in memory
|
| 1278 |
+
|
| 1279 |
+
page = pdf_document[0] # First page
|
| 1280 |
+
print(f"length of locations 0 from not sec presence: {len(locations[0])}")
|
| 1281 |
+
|
| 1282 |
+
for loc in locations:
|
| 1283 |
+
|
| 1284 |
+
if len(loc) == 3:
|
| 1285 |
+
coor, lbl, clr = loc
|
| 1286 |
+
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1287 |
+
for cor in coor:
|
| 1288 |
+
#Create a Circle annotation (Count Markup)
|
| 1289 |
+
annot = page.add_circle_annot(
|
| 1290 |
+
fitz.Rect(cor[0] - 10, cor[1] - 10, cor[0] + 10, cor[1] + 10) # Small circle
|
| 1291 |
+
)
|
| 1292 |
+
|
| 1293 |
+
#Assign required Bluebeam metadata
|
| 1294 |
+
annot.set_colors(stroke=clr, fill=(1, 1, 1)) # Set stroke color and fill white
|
| 1295 |
+
annot.set_border(width=2) # Border thickness
|
| 1296 |
+
annot.set_opacity(1) # Fully visible
|
| 1297 |
+
|
| 1298 |
+
#Set annotation properties for Bluebeam Count detection
|
| 1299 |
+
annot.set_info("name", lbl) # Unique name for each count
|
| 1300 |
+
annot.set_info("subject", "Count") #Bluebeam uses "Count" for Count markups
|
| 1301 |
+
annot.set_info("title", lbl) # Optional
|
| 1302 |
+
annot.update() # Apply changes
|
| 1303 |
+
if len(loc) == 4:
|
| 1304 |
+
coor, lbl, clr,w = loc
|
| 1305 |
+
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1306 |
+
for cor in coor:
|
| 1307 |
+
#Create a Circle annotation (Count Markup)
|
| 1308 |
+
annot = page.add_circle_annot(
|
| 1309 |
+
fitz.Rect(cor[0] - 10, cor[1] - 10, cor[0] + 10, cor[1] + 10) # Small circle
|
| 1310 |
+
)
|
| 1311 |
+
|
| 1312 |
+
#Assign required Bluebeam metadata
|
| 1313 |
+
annot.set_colors(stroke=clr, fill=(1, 1, 1)) # Set stroke color and fill white
|
| 1314 |
+
annot.set_border(width=2) # Border thickness
|
| 1315 |
+
annot.set_opacity(1) # Fully visible
|
| 1316 |
+
|
| 1317 |
+
#Set annotation properties for Bluebeam Count detection
|
| 1318 |
+
annot.set_info("name", lbl) # Unique name for each count
|
| 1319 |
+
annot.set_info("subject", "Count") #Bluebeam uses "Count" for Count markups
|
| 1320 |
+
annot.set_info("title", lbl) # Optional
|
| 1321 |
+
annot.update() # Apply changes
|
| 1322 |
+
|
| 1323 |
+
if len(loc) == 5:
|
| 1324 |
+
coor, lbl, clr,w,h = loc
|
| 1325 |
+
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 1326 |
+
for cor in coor:
|
| 1327 |
+
#Create a Circle annotation (Count Markup)
|
| 1328 |
+
annot = page.add_circle_annot(
|
| 1329 |
+
fitz.Rect(cor[0] - 10, cor[1] - 10, cor[0] + 10, cor[1] + 10) # Small circle
|
| 1330 |
+
)
|
| 1331 |
+
|
| 1332 |
+
#Assign required Bluebeam metadata
|
| 1333 |
+
annot.set_colors(stroke=clr, fill=(1, 1, 1)) # Set stroke color and fill white
|
| 1334 |
+
annot.set_border(width=2) # Border thickness
|
| 1335 |
+
annot.set_opacity(1) # Fully visible
|
| 1336 |
+
|
| 1337 |
+
#Set annotation properties for Bluebeam Count detection
|
| 1338 |
+
annot.set_info("name", lbl) # Unique name for each count
|
| 1339 |
+
annot.set_info("subject", "Count") #Bluebeam uses "Count" for Count markups
|
| 1340 |
+
annot.set_info("title", lbl) # Optional
|
| 1341 |
+
annot.update() # Apply changes
|
| 1342 |
+
|
| 1343 |
+
#Save modified PDF to a variable instead of a file
|
| 1344 |
+
output_stream = io.BytesIO()
|
| 1345 |
+
pdf_document.save(output_stream)
|
| 1346 |
+
pdf_document.close()
|
| 1347 |
+
|
| 1348 |
+
return output_stream.getvalue() # Return the modified PDF as bytes
|
| 1349 |
|
| 1350 |
|
| 1351 |
def get_user_input(user_words):
|