Skip to content
This repository was archived by the owner on Jan 9, 2021. It is now read-only.

Commit 73855f6

Browse files
committed
1.4 / 1.5 compatibility
1 parent 1853b01 commit 73855f6

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ Example:
55

66
# Commit an IFC file into a newly created project
77

8+
import base64
9+
import bimserver
10+
11+
client = bimserver.api(server_address, username, password)
12+
13+
deserializer_id = client.ServiceInterface.getDeserializerByName(deserializerName='Ifc2x3tc1 (Streaming)').get('oid')
14+
project_id = client.ServiceInterface.addProject(projectName="My new project", schema="ifc2x3tc1").get('oid')
15+
16+
with open(fn, "rb") as f:
17+
ifc_data = f.read()
18+
19+
client.ServiceInterface.checkin(
20+
poid= project_id,
21+
comment= "my first commit",
22+
deserializerOid= deserializer_id,
23+
fileSize= len(ifc_data),
24+
fileName= "IfcOpenHouse.ifc",
25+
data= base64.b64encode(ifc_data).decode('utf-8'),
26+
sync= "false",
27+
merge= "false"
28+
)
29+
30+
Or for BIMserver version 1.4:
31+
32+
# Commit an IFC file into a newly created project
33+
834
import base64
935
import bimserver
1036

bimserver.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,23 @@ def __init__(self, hostname, username=None, password=None):
5555
self.MetaInterface.getServiceInterfaces()
5656
))
5757

58+
self.version = "1.4" if "Bimsie1AuthInterface" in self.interfaces else "1.5"
59+
5860
if username is not None and password is not None:
59-
self.token = self.Bimsie1AuthInterface.login(
61+
auth_interface = getattr(self, "Bimsie1AuthInterface", getattr(self, "AuthInterface"))
62+
self.token = auth_interface.login(
6063
username=username,
6164
password=password
6265
)
6366

6467
def __getattr__(self, interface):
6568
if self.interfaces is not None and interface not in self.interfaces:
69+
70+
# Some form of compatibility:
71+
if self.version == "1.4" and not interface.startswith("Bimsie1"):
72+
return self.__getattr__("Bimsie1" + interface)
73+
elif self.version == "1.5" and interface.startswith("Bimsie1"):
74+
return self.__getattr__(interface[len("Bimsie1"):])
75+
6676
raise AttributeError("'%s' is does not name a valid interface on this server" % interface)
6777
return api.interface(self, interface)

0 commit comments

Comments
 (0)