### Handle BIMserver Exceptions and Errors Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Demonstrates how to catch and handle BIMserver-specific exceptions (`BimserverException`) as well as general exceptions. Includes examples for handling non-existent projects and projects with existing names, providing specific error messages. Requires a connected BIMserver client. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") try: # Attempt to get a non-existent project project = client.ServiceInterface.getProjectByPoid(poid=999999) print(f"Project found: {project['name']}") except bimserver.BimserverException as e: print(f"BIMserver error: {e}") # Handle specific error cases if "not found" in str(e).lower(): print("The requested project does not exist") elif "permission" in str(e).lower(): print("You don't have permission to access this resource") else: print("An unknown BIMserver error occurred") except Exception as e: print(f"Unexpected error: {type(e).__name__}: {e}") # Try creating a project with validation try: new_project = client.ServiceInterface.addProject( projectName="Test Project", schema="ifc2x3tc1" ) print(f"Project created successfully: {new_project['oid']}") except bimserver.BimserverException as e: if "already exists" in str(e).lower(): print("A project with this name already exists") # Get existing project instead projects = client.ServiceInterface.getProjectsByName(name="Test Project") if projects: print(f"Using existing project: {projects[0]['oid']}") else: raise ``` -------------------------------- ### Query Projects and Get Project Details Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Searches for projects and retrieves detailed information about project structure, revisions, and metadata. ```APIDOC ## Query Projects and Get Project Details ### Description Searches for projects and retrieves detailed information about project structure, revisions, and metadata. ### Method POST ### Endpoint `/bimserver/service/ServiceInterface/getProjectsByName` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body ##### `getProjectsByName` - **name** (string) - Required - The name of the project to search for. ### Request Example ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # To get all projects, you might need to use a different method or iterate. # Example for searching by name: project_name = "Office Building Renovation" projects = client.ServiceInterface.getProjectsByName(name=project_name) if projects: print(f"Found projects matching '{project_name}':") for project in projects: print(f"- Name: {project['name']}, ID: {project['oid']}, Last Revision: {project.get('lastRevisionId', 'N/A')}") else: print(f"No projects found matching '{project_name}'.") ``` ### Response #### Success Response (200) - **projects** (array of objects) - A list of project objects, each containing details like 'oid', 'name', and 'lastRevisionId'. #### Response Example ```json [ { "oid": 123, "name": "Office Building Renovation", "description": "", "schema": "ifc2x3tc1", "lastRevisionId": 456, "token": "..." } ] ``` ``` -------------------------------- ### BIMserver 1.4 Compatibility and File Upload Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Connects to older BIMserver 1.4 installations, automatically detecting the version. It demonstrates using Bimsie1 interfaces to get a deserializer, create a project, and upload an IFC file asynchronously. Requires a BIMserver instance running at the specified address and valid credentials. ```python import base64 import bimserver # Client automatically detects version client = bimserver.Api("http://old-server:8082", "admin", "password") print(f"Detected BIMserver version: {client.version}") if client.version == "1.4": # For version 1.4, use Bimsie1 interfaces explicitly deserializer = client.Bimsie1ServiceInterface.getSuggestedDeserializerForExtension( extension="ifc" ) deserializer_id = deserializer.get('oid') # Create project (simpler API in 1.4) project = client.Bimsie1ServiceInterface.addProject( projectName="Legacy Project" ) project_id = project.get('oid') # Upload file with async checkin with open("model.ifc", "rb") as f: ifc_data = f.read() client.Bimsie1ServiceInterface.checkin( poid=project_id, comment="Initial commit", deserializerOid=deserializer_id, fileSize=len(ifc_data), fileName="model.ifc", data=base64.b64encode(ifc_data).decode('utf-8'), sync=False ) print("File uploaded successfully (async)") else: # Version 1.5+ uses ServiceInterface # The client provides automatic compatibility via __getattr__ # You can use either Bimsie1ServiceInterface or ServiceInterface deserializer = client.ServiceInterface.getDeserializerByName( deserializerName='Ifc2x3tc1 (Streaming)' ) print(f"Using version 1.5+ interface: {deserializer['name']}") ``` -------------------------------- ### Get All Projects and Revisions - Python Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Fetches all top-level, active projects from BIMserver and iterates through them to display project details. It also retrieves the last three revisions for each project and prints their comments. Requires a connected BIMserver client. ```python all_projects = client.ServiceInterface.getAllProjects( onlyTopLevel=True, onlyActive=True ) print(f"Total projects: {len(all_projects)}") for project in all_projects: print(f"\nProject: {project['name']}") print(f" ID: {project['oid']}") print(f" Schema: {project['schema']}") print(f" Last revision: {project['lastRevisionId']}") print(f" Created: {project['createdDate']}") # Get revisions for this project if project['lastRevisionId']: revisions = client.ServiceInterface.getAllRevisionsOfProject( poid=project['oid'] ) print(f" Total revisions: {len(revisions)}") for revision in revisions[-3:]: print(f" - Rev {revision['id']}: {revision['comment']}") ``` -------------------------------- ### Get Server Information and Version - Python Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Fetches comprehensive server information, including version details, uptime, and counts of projects, users, revisions, and checkouts. It also includes a check to verify if the BIMserver meets a specified minimum version requirement. Requires a connected BIMserver client. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Get complete server information server_info = client.AdminInterface.getServerInfo() print("BIMserver Information:") print(f" Version: {server_info['version']['major']}.{server_info['version']['minor']}.{server_info['version']['revision']}") print(f" Started: {server_info['started']}") print(f" Uptime: {server_info['uptime']} ms") print(f" Projects: {server_info['numberOfProjects']}") print(f" Users: {server_info['numberOfUsers']}") print(f" Revisions: {server_info['numberOfRevisions']}") print(f" Checkouts: {server_info['numberOfCheckouts']}") # Check if server meets minimum version requirement requires_version = [1, 5, 183] # major, minor, revision is_compatible = client.minimumBimServerVersion(requires_version) if is_compatible: print(f"\n✓ Server meets minimum version {'.'.join(map(str, requires_version))}") else: print(f"\n✗ Server does not meet minimum version {'.'.join(map(str, requires_version))}") ``` -------------------------------- ### Get Project Revisions and Details Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Retrieves all revisions for a given project, prints their details, fetches the latest revision summary including entity counts, and compares the two most recent revisions. Requires a connected BIMserver client and a valid project ID. ```python revisions = client.ServiceInterface.getAllRevisionsOfProject(poid=project_id) print(f"Project has {len(revisions)} revisions:") for revision in revisions: print(f"\nRevision {revision['id']}:") print(f" Comment: {revision['comment']}") print(f" Date: {revision['date']}") print(f" User: {revision['user']['name']}") print(f" Size: {revision['size']} bytes") print(f" Checksum: {revision['checksum']}") # Get specific revision details if revisions: latest_revision = revisions[-1] revision_id = latest_revision['oid'] revision_summary = client.ServiceInterface.getRevisionSummary(roid=revision_id) print(f"\nLatest revision summary:") print(f" IFC entities: {len(revision_summary['list'])}") # Show entity counts for entity in revision_summary['list'][:10]: # First 10 entity types print(f" - {entity['name']}: {entity['count']} instances") # Compare two revisions (if multiple exist) if len(revisions) >= 2: compare_type = client.ServiceInterface.compare( roid1=revisions[-2]['oid'], roid2=revisions[-1]['oid'], sCompareType="ALL" ) print(f"\nComparison between revisions: {compare_type}") ``` -------------------------------- ### Dynamic Method Invocation on BIMserver Interface Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Demonstrates how to dynamically get an interface and method from the client object using `getattr`. This allows for flexible interaction with BIMserver functionalities where the interface or method name might be determined at runtime. It retrieves all projects with specific filters. ```python interface_name = "ServiceInterface" method_name = "getAllProjects" interface = getattr(client, interface_name) method = getattr(interface, method_name) projects = method(onlyTopLevel=True, onlyActive=True) print(f"Dynamic call returned {len(projects)} projects") ``` -------------------------------- ### Download Latest Revision from Project using bimserver.api Source: https://github.com/opensourcebim/python-bimserver-client/blob/master/README.md Downloads the latest revision of an IFC file from a specified project. It requires the server address, username, password, and project name. The function retrieves project details, identifies the serializer, gets the last revision ID, initiates the download, and saves the result as a zip file. ```python import json from urllib import request project_name = "MyProject" client = bimserver.api(server_address, username, password) projects = client.ServiceInterface.getProjectsByName(name=project_name) project = projects[0] serializer = client.ServiceInterface.getSerializerByName(serializerName='Ifc4 (Streaming)') serializer_id = serializer.get('oid') roid = projects[0].get('lastRevisionId') topicId = client.ServiceInterface.download( roids= [roid], serializerOid= serializer_id, query= json.dumps({}), sync= False ) download_url = f"{server_address}/download?token={client.token}&zip=on&topicId={topicId}" res = request.urlopen(download_url) with open('res.zip', 'wb') as d: d.write(res.read()) ``` -------------------------------- ### Working with Revisions and Comparisons - Python (Placeholder) Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt This snippet is a placeholder for code related to accessing specific revisions, comparing different project versions, and retrieving revision metadata. The actual implementation would involve calling methods on the BIMserver client to fetch and process revision data. Requires a connected BIMserver client and a valid project ID. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") project_id = 123456 # Replace with actual project ID # Further code for revision operations would go here... ``` -------------------------------- ### Create Project and Upload IFC File to BIMserver Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Adds a new project to BIMserver and commits an IFC file as its initial revision. The IFC file is encoded using base64 for transfer. Requires an existing BIMserver client connection, project name, schema, and the IFC file path. Outputs the revision ID upon successful check-in. ```python import base64 import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Get the appropriate deserializer for IFC 2x3 deserializer = client.ServiceInterface.getDeserializerByName( deserializerName='Ifc2x3tc1 (Streaming)' ) deserializer_id = deserializer.get('oid') # Create a new project project = client.ServiceInterface.addProject( projectName="Office Building Renovation", schema="ifc2x3tc1" ) project_id = project.get('oid') # Read and upload IFC file with open("IfcOpenHouse.ifc", "rb") as f: ifc_data = f.read() # Commit the file to the project result = client.ServiceInterface.checkinSync( poid=project_id, comment="Initial upload of architectural model", deserializerOid=deserializer_id, fileSize=len(ifc_data), fileName="IfcOpenHouse.ifc", data=base64.b64encode(ifc_data).decode('utf-8'), merge=False ) print(f"File checked in successfully. Revision ID: {result}") ``` -------------------------------- ### Manage Users and Permissions - Python Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Demonstrates user management operations in BIMserver, including adding a new user, retrieving all existing users, adding a user to a specific project, and changing a user's password. Requires a connected BIMserver client with administrative privileges. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Add a new user new_user = client.ServiceInterface.addUser( username="john.doe@example.com", name="John Doe", userType="USER", selfRegistration=False, resetUrl="" ) user_id = new_user.get('oid') print(f"Created user: {new_user['name']} (ID: {user_id})") # Get all users all_users = client.ServiceInterface.getAllUsers() print(f"\nTotal users: {len(all_users)}") for user in all_users: print(f" - {user['name']} ({user['username']})") print(f" Type: {user['userType']}") print(f" State: {user['state']}") # Add user to project with specific rights project_id = 123456 # Replace with actual project ID client.ServiceInterface.addUserToProject( uoid=user_id, poid=project_id ) # Change user password (requires admin privileges) client.ServiceInterface.changePassword( uoid=user_id, oldPassword="", # Empty for admin reset newPassword="NewSecurePassword123" ) print(f"\nUser {new_user['name']} added to project and password set") ``` -------------------------------- ### Initialize API Client Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Creates an authenticated connection to a BIMserver instance, automatically discovering all available service interfaces and methods from the server. ```APIDOC ## Initialize API Client ### Description Creates an authenticated connection to a BIMserver instance, automatically discovering all available service interfaces and methods from the server. ### Method POST (Implicit via client initialization) ### Endpoint `/` (Connection to BIMserver address) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (Connection details are passed as arguments) ### Request Example ```python import bimserver server_address = "http://localhost:8082" username = "admin@bimserver.org" password = "admin" client = bimserver.Api(server_address, username, password) ``` ### Response #### Success Response (200) - **client** (object) - An initialized API client object with access to BIMserver services. #### Response Example ```python # Access server version print(f"Connected to BIMserver version: {client.version}") # List available interfaces print(f"Available interfaces: {client.interfaceNames}") ``` ``` -------------------------------- ### Initialize API Client for BIMserver Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Establishes an authenticated connection to a BIMserver instance. It automatically discovers all available service interfaces and methods from the server, providing access to server version and interface names. Requires server address, username, and password. ```python import bimserver # Connect to BIMserver with authentication server_address = "http://localhost:8082" username = "admin@bimserver.org" password = "admin" client = bimserver.Api(server_address, username, password) # Access server version print(f"Connected to BIMserver version: {client.version}") # List available interfaces print(f"Available interfaces: {client.interfaceNames}") # The client now has attributes for all service interfaces: # - client.ServiceInterface # - client.AuthInterface # - client.AdminInterface # - client.SettingsInterface # etc. ``` -------------------------------- ### Create Project and Upload IFC File Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Adds a new project to BIMserver and commits an IFC file as the initial revision using base64 encoding for file transfer. ```APIDOC ## Create Project and Upload IFC File ### Description Adds a new project to BIMserver and commits an IFC file as the initial revision using base64 encoding for file transfer. ### Method POST ### Endpoint `/bimserver/service/ServiceInterface/addProject` `/bimserver/service/ServiceInterface/checkinSync` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body ##### `addProject` - **projectName** (string) - Required - The name of the new project. - **schema** (string) - Required - The schema name for the project (e.g., 'ifc2x3tc1'). ##### `checkinSync` - **poid** (integer) - Required - The project object ID. - **comment** (string) - Required - A comment for the revision. - **deserializerOid** (integer) - Required - The OID of the deserializer to use. - **fileSize** (integer) - Required - The size of the file in bytes. - **fileName** (string) - Required - The name of the file. - **data** (string) - Required - The base64 encoded content of the IFC file. - **merge** (boolean) - Required - Whether to merge with the previous revision. ### Request Example ```python import base64 import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") deserializer = client.ServiceInterface.getDeserializerByName(deserializerName='Ifc2x3tc1 (Streaming)') deserializer_id = deserializer.get('oid') project = client.ServiceInterface.addProject(projectName="Office Building Renovation", schema="ifc2x3tc1") project_id = project.get('oid') with open("IfcOpenHouse.ifc", "rb") as f: ifc_data = f.read() result = client.ServiceInterface.checkinSync( poid=project_id, comment="Initial upload of architectural model", deserializerOid=deserializer_id, fileSize=len(ifc_data), fileName="IfcOpenHouse.ifc", data=base64.b64encode(ifc_data).decode('utf-8'), merge=False ) ``` ### Response #### Success Response (200) - **result** (string) - The revision ID of the uploaded file. #### Response Example ```python print(f"File checked in successfully. Revision ID: {result}") ``` ``` -------------------------------- ### List Deserializers and Serializers - Python Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Retrieves and lists all enabled deserializers (for importing) and serializers (for exporting) supported by the BIMserver instance. It also demonstrates how to find a suggested deserializer for a specific file extension like 'ifc'. Requires a connected BIMserver client. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Get all deserializers (for importing) deserializers = client.ServiceInterface.getAllDeserializers(onlyEnabled=True) print("Available Deserializers (Import Formats):") for deserializer in deserializers: print(f" - {deserializer['name']}") print(f" Extension: {deserializer['defaultExtension']}") print(f" Enabled: {deserializer['enabled']}") # Get all serializers (for exporting) serializers = client.ServiceInterface.getAllSerializers(onlyEnabled=True) print("\nAvailable Serializers (Export Formats):") for serializer in serializers: print(f" - {serializer['name']}") print(f" Extension: {serializer['defaultExtension']}") print(f" Enabled: {serializer['enabled']}") # Get specific deserializer by extension ifc_deserializer = client.ServiceInterface.getSuggestedDeserializerForExtension( extension="ifc" ) print(f"\nSuggested IFC deserializer: {ifc_deserializer['name']}") ``` -------------------------------- ### Query BIMserver Projects for Details Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Searches for projects within BIMserver and retrieves detailed information, including project structure, revisions, and metadata. Requires an initialized BIMserver client connection. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Example: Get all projects (or use getProjectsByName for specific searches) all_projects = client.ServiceInterface.getProjects() for proj in all_projects: print(f"Project Name: {proj['name']}, ID: {proj['oid']}, Last Revision: {proj.get('lastRevisionId', 'N/A')}") # Example: Get details for a specific project by name project_name_to_find = "Office Building Renovation" projects_found = client.ServiceInterface.getProjectsByName(name=project_name_to_find) if projects_found: specific_project = projects_found[0] print(f"\nDetails for '{project_name_to_find}':") print(f" ID: {specific_project['oid']}") print(f" Schema: {specific_project['schema']}") # Further details can be retrieved using specific methods if needed ``` -------------------------------- ### Commit IFC to Project for BIMserver 1.4 Source: https://github.com/opensourcebim/python-bimserver-client/blob/master/README.md Commits an IFC file to a newly created project using the Bimsie1ServiceInterface, compatible with BIMserver version 1.4. This method requires server credentials and the IFC file. It finds the appropriate deserializer, creates a project, and then checks in the file with specified parameters. ```python # Commit an IFC file into a newly created project import base64 import bimserver client = bimserver.api(server_address, username, password) deserializer_id = client.Bimsie1ServiceInterface.getSuggestedDeserializerForExtension(extension="ifc").get('oid') project_id = client.Bimsie1ServiceInterface.addProject(projectName="My new project").get('oid') with open("IfcOpenHouse.ifc", "rb") as f: ifc_data = f.read() client.Bimsie1ServiceInterface.checkin( poid= project_id, comment= "my first commit", deserializerOid= deserializer_id, fileSize= len(ifc_data), fileName= "IfcOpenHouse.ifc", data= base64.b64encode(ifc_data).decode('utf-8'), sync= False ) ``` -------------------------------- ### Commit IFC to Project using bimserver.api Source: https://github.com/opensourcebim/python-bimserver-client/blob/master/README.md Commits an IFC file to a newly created project using the bimserver.api client. It requires the server address, username, password, and the path to the IFC file. The function handles project creation, deserializer identification, file reading, base64 encoding, and then checks in the file. ```python import base64 import bimserver client = bimserver.api(server_address, username, password) deserializer_id = client.ServiceInterface.getDeserializerByName(deserializerName='Ifc2x3tc1 (Streaming)').get('oid') project_id = client.ServiceInterface.addProject(projectName="My new project", schema="ifc2x3tc1").get('oid') with open(fn, "rb") as f: ifc_data = f.read() client.ServiceInterface.checkinSync( poid= project_id, comment= "my first commit", deserializerOid= deserializer_id, fileSize= len(ifc_data), fileName= "IfcOpenHouse.ifc", data= base64.b64encode(ifc_data).decode('utf-8'), merge= False ) ``` -------------------------------- ### Custom Low-Level API Requests Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Shows how to make direct, low-level API calls to any BIMserver interface and method using `client.make_request`. It also demonstrates how to retrieve the authentication token for external API usage. Requires a connected BIMserver client. ```python import bimserver client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Make a low-level request directly response = client.make_request( interface="ServiceInterface", method="getAllProjects", onlyTopLevel=True, onlyActive=True ) print(f"Direct API call returned {len(response)} projects") # Access token for external API calls print(f"Authentication token: {client.token}") ``` -------------------------------- ### Download Latest Revision from Project Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Retrieves the most recent IFC file from a project by name, serializes it to the desired format, and downloads as a ZIP archive. ```APIDOC ## Download Latest Revision from Project ### Description Retrieves the most recent IFC file from a project by name, serializes it to the desired format, and downloads as a ZIP archive. ### Method POST ### Endpoint `/bimserver/service/ServiceInterface/getProjectsByName` `/bimserver/service/ServiceInterface/getSerializerByName` `/bimserver/service/ServiceInterface/download` `/download` (for retrieving the file) ### Parameters #### Path Parameters None #### Query Parameters - **token** (string) - Required - Authentication token. - **zip** (boolean) - Required - Whether to return the file as a zip archive. - **topicId** (string) - Required - The ID of the download topic. #### Request Body ##### `getProjectsByName` - **name** (string) - Required - The name of the project to search for. ##### `getSerializerByName` - **serializerName** (string) - Required - The name of the serializer (e.g., 'Ifc4 (Streaming)'). ##### `download` - **roids** (array of integers) - Required - List of revision object IDs to download. - **serializerOid** (integer) - Required - The OID of the serializer. - **query** (string) - Optional - JSON string for query parameters. - **sync** (boolean) - Optional - Whether to perform a synchronous download. ### Request Example ```python import json import bimserver from urllib import request client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") project_name = "Office Building Renovation" projects = client.ServiceInterface.getProjectsByName(name=project_name) if not projects: raise Exception(f"Project '{project_name}' not found") project = projects[0] serializer = client.ServiceInterface.getSerializerByName(serializerName='Ifc4 (Streaming)') serializer_id = serializer.get('oid') revision_id = project.get('lastRevisionId') topic_id = client.ServiceInterface.download(roids=[revision_id], serializerOid=serializer_id, query=json.dumps({}), sync=False) server_address = "http://localhost:8082" download_url = f"{server_address}/download?token={client.token}&zip=on&topicId={topic_id}" response = request.urlopen(download_url) with open('latest_revision.zip', 'wb') as output_file: output_file.write(response.read()) ``` ### Response #### Success Response (200) - **response** (file) - The downloaded IFC file as a ZIP archive. #### Response Example ```python print("Download complete: latest_revision.zip") ``` ``` -------------------------------- ### Download Latest IFC Revision from BIMserver Project Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Retrieves the most recent IFC file from a specified BIMserver project. It serializes the file to the 'Ifc4 (Streaming)' format and downloads it as a ZIP archive. Requires a BIMserver client, project name, and server address. Outputs a 'latest_revision.zip' file. ```python import json import bimserver from urllib import request client = bimserver.Api("http://localhost:8082", "admin@bimserver.org", "admin") # Find project by name project_name = "Office Building Renovation" projects = client.ServiceInterface.getProjectsByName(name=project_name) if not projects: raise Exception(f"Project '{project_name}' not found") project = projects[0] print(f"Found project: {project['name']} (ID: {project['oid']})") # Get serializer for export format serializer = client.ServiceInterface.getSerializerByName( serializerName='Ifc4 (Streaming)' ) serializer_id = serializer.get('oid') # Get latest revision ID revision_id = project.get('lastRevisionId') # Initiate download process topic_id = client.ServiceInterface.download( roids=[revision_id], serializerOid=serializer_id, query=json.dumps({}), sync=False ) # Download the file using the topic ID server_address = "http://localhost:8082" # Assumed from context, should ideally be passed or retrieved download_url = f"{server_address}/download?token={client.token}&zip=on&topicId={topic_id}" response = request.urlopen(download_url) with open('latest_revision.zip', 'wb') as output_file: output_file.write(response.read()) print("Download complete: latest_revision.zip") ``` -------------------------------- ### Enable Autocompletion in Python 2 Source: https://github.com/opensourcebim/python-bimserver-client/blob/master/README.md Enables tab autocompletion for the Python interpreter in version 2. This is achieved by importing the 'rlcompleter' module and configuring the 'readline' module to parse and bind the tab key to the 'complete' action. ```python import rlcompleter, readline readline.parse_and_bind('tab:complete') ``` -------------------------------- ### Make Authenticated Request to Custom Endpoint Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Constructs a download URL using the client's base URL and token for authenticated access to a custom endpoint. This is useful for interacting with specific download functionalities exposed by the BIMserver. ```python download_url = f"{client.url.replace('/json', '')}/download" print(f"Download endpoint: {download_url}?token={client.token}") ``` -------------------------------- ### Check Interface Availability and Access Methods Source: https://context7.com/opensourcebim/python-bimserver-client/llms.txt Checks if a specific interface, such as 'GeometryInterface', is available on the BIMserver. If available, it demonstrates accessing methods like 'getGeometryInfo' from that interface. This allows for conditional execution of BIM-related operations. ```python if "GeometryInterface" in client.interfaceNames: print("Geometry operations are available") # Access geometry-related methods geometry_info = client.GeometryInterface.getGeometryInfo(roid=12345) else: print("Geometry interface not available on this server") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.