### Untitled No description -------------------------------- ### Clone and Install BDNS Project Dependencies Source: https://github.com/theodi/bdns/blob/main/README.md This snippet outlines the initial steps to set up the BDNS project locally. It involves cloning the repository, navigating into the project directory, and installing environment dependencies using pixi. It also includes installing tinytex, which is required for PDF generation. ```bash git clone https://github.com/theodi/BDNS.git cd BDNS pixi install pixi run install-tinytex ``` -------------------------------- ### Example: Prefix Format Label Source: https://github.com/theodi/bdns/blob/main/BDNS_Specification_naming_syntax.md An example illustrating the combination of location code prefix with a device name. ```text UK-LON-BLD1_TSTAT-1 ``` -------------------------------- ### Untitled No description -------------------------------- ### Build BDNS Documentation Locally Source: https://github.com/theodi/bdns/blob/main/README.md This code snippet demonstrates how to build the BDNS documentation locally after setting up the project and its dependencies. It assumes the user has already cloned the repository and installed the necessary environment using pixi. ```bash pixi run build-docs ``` -------------------------------- ### Untitled No description -------------------------------- ### Example: Suffix Format Label Source: https://github.com/theodi/bdns/blob/main/BDNS_Specification_naming_syntax.md Demonstrates how the optional suffix can be used to append practical information for maintenance technicians, such as room, distribution board, or sensor details. ```text TSTAT-1_RH-2-3-25-CO2 ``` ```text TSTAT-2_EF ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Create QR Code Payload and Image (Python) Source: https://context7.com/theodi/bdns/llms.txt Generates a minified JSON payload for QR codes containing device identification (GUID, site, name) and creates a QR code image from the payload. Dependencies: `json`, `qrcode`, `io.BytesIO`. ```Python import json import qrcode from io import BytesIO def generate_qr_payload( guid: str, site_code: str, asset_name: str, guid_scheme: str = "ifc" ) -> str: """ Generate minified JSON payload for QR code physical labels. Site code format: -- - COUNTRY: ISO Alpha-2 code (e.g., GB, US) - CITY: UN LOCODE (e.g., LON for London) - BUILDING: Project-specific abbreviation """ payload = { "asset": { "guid": f"{guid_scheme}://{guid}", "site": site_code, "name": asset_name } } # Minify JSON (no spaces) return json.dumps(payload, separators=(',', ':')) def create_qr_code(payload: str, output_path: str = None) -> BytesIO: """Generate QR code image from payload.""" qr = qrcode.QRCode(version=1, box_size=10, border=4) qr.add_data(payload) qr.make(fit=True) img = qr.make_image(fill_color="black", back_color="white") if output_path: img.save(output_path) # Return as BytesIO for in-memory use buffer = BytesIO() img.save(buffer, format='PNG') buffer.seek(0) return buffer # Example: Air Handling Unit in London building payload = generate_qr_payload( guid="04aEp5ymD_$u5IxhJN2aGi", site_code="GB-LON-BLD1", asset_name="AHU-1" ) print(f"QR Payload: {payload}") # Output: {"asset":{"guid":"ifc://04aEp5ymD_$u5IxhJN2aGi","site":"GB-LON-BLD1","name":"AHU-1"}} # Generate QR code qr_image = create_qr_code(payload, "ahu_label.png") print("✓ QR code generated") # Example with UUID (non-BIM workflow) payload_uuid = generate_qr_payload( guid="d3501378-dd50-47c5-ae26-806726e1b749", site_code="US-NYC-TWR2", asset_name="TSTAT-145", guid_scheme="uuid" ) print(f"UUID Payload: {payload_uuid}") ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### GUID Validation Regex - Hexadecimal Source: https://github.com/theodi/bdns/blob/main/BDNS_Specification_naming_syntax.md Regular expression to validate the format of a 32-digit hexadecimal GUID, commonly generated by GUID tools. Ensures the correct structure and character set for hexadecimal representation. ```regex ([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12} ``` -------------------------------- ### Untitled No description -------------------------------- ### Generate and Validate Device GUIDs (Python) Source: https://context7.com/theodi/bdns/llms.txt Generates GUIDs in RFC 4122 (uuid) or a simplified IFC base64 format. Also validates the format of given GUIDs. Dependencies include `uuid` and `re`. ```Python import uuid import re def generate_device_guid(format_type: str = "uuid") -> str: """ Generate a globally unique identifier for a device instance. Supports 'uuid' (RFC 4122) or 'ifc' (IFC base64) formats. GUIDs are immutable and unique to device instances. """ if format_type == "uuid": return str(uuid.uuid4()) elif format_type == "ifc": # Simplified IFC base64 representation (22 characters) # In production, use proper IFC GUID converter guid = uuid.uuid4() # IFC uses base64 with _ and $ instead of / and + return "04aEp5ymD_$u5IxhJN2aGi" # Example format else: raise ValueError("format_type must be 'uuid' or 'ifc'") def validate_guid(guid: str, format_type: str = "uuid") -> bool: """Validate GUID format.""" if format_type == "uuid": pattern = r'^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$' return bool(re.match(pattern, guid)) elif format_type == "ifc": pattern = r'^[A-Za-z0-9_$]{22}$' return bool(re.match(pattern, guid)) return False # Generate GUIDs uuid_guid = generate_device_guid("uuid") print(f"UUID GUID: {uuid_guid}") # Example: 58e6591f-0cef-4bb1-ac9c-6ef03ec58111 ifc_guid = generate_device_guid("ifc") print(f"IFC GUID: {ifc_guid}") # Example: 04aEp5ymD_$u5IxhJN2aGi # Validate GUIDs assert validate_guid("58e6591f-0cef-4bb1-ac9c-6ef03ec58111", "uuid") assert validate_guid("04aEp5ymD_$u5IxhJN2aGi", "ifc") print("✓ GUID validation successful") ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### GUID Validation Regex - IFC Base64 Source: https://github.com/theodi/bdns/blob/main/BDNS_Specification_naming_syntax.md Regular expression to validate the format of an IFC Base64 encoded GUID. This format is typically used when generated by BIM software and ensures the correct length and character set for IFC compatibility. ```regex [A-Za-z0-9_$]{22} ```