-
Notifications
You must be signed in to change notification settings - Fork 630
Open
Description
Describe the bug
I'm using the python bimserver client to try and download a spatial subset of an IFC model and I'm running into the following issues:
- I can't get the
NotificationRegistryInterface.getProgress()
to work reliably, this is probably a user error because the web interface seems to handle this fine (but maybe partly with websockets?) I only get state=STARTED even when the subsequent download works fine. - The result for my
inBoundingBox
query seems to be always empty. I tried various permutations of this. This also seems to be the case in bimvie.ws - (I can foresee some issues in the ifc2x3tc1-stdlib:... approach, without the includes one gets a file with just those direct elements, but let's say I want to write a query for all IfcMaterialLayerSets and I want the result to include the traversal to all layers + materials, are the includes for every potential attribute needed, is there a generic forward traversal? Also the fact that this is schema specific seems non-optimal, what if I would want to query multiple roids with diverse schemas (assuming this becomes possible at some point))
To Reproduce
Python script:
python
import json
from pathlib import Path
import sys
from time import sleep
import ifcopenshell
import base64
sys.path.append(str(Path(__file__).resolve().parent / "python-bimserver-client"))
import bimserver
hostname = "http://localhost:9000"
client = bimserver.Api(hostname, "[email protected]", "admin")
serializer_id = client.ServiceInterface.getSerializerByName(serializerName="Ifc2x3tc1 (Streaming)").get("oid")
deserializer_id = client.ServiceInterface.getDeserializerByName(deserializerName="Ifc2x3tc1 (Streaming)").get("oid")
def get_or_create_project(name):
existing = client.ServiceInterface.getProjectsByName(name=name)
if existing:
return existing[0].get("oid")
else:
return client.ServiceInterface.addProject(projectName=name, schema="ifc2x3tc1").get("oid")
project_id = get_or_create_project("Duplex (arch)")
revision_id = client.ServiceInterface.getProjectByPoid(poid=project_id).get("lastRevisionId")
if revision_id == -1:
with open("Duplex_A_20110907_optimized.ifc", "rb") as f:
ifc_data = f.read()
revision_id = client.ServiceInterface.checkinSync(
poid=project_id,
comment="my first commit",
deserializerOid=deserializer_id,
fileSize=len(ifc_data),
fileName="Duplex_A_20110907_optimized.ifc",
data=base64.b64encode(ifc_data).decode("utf-8"),
sync="false",
merge="false",
).get("roid")
query = {
"type": {"name": "IfcWall", "includeAllSubTypes": True},
"includes": [
"ifc2x3tc1-stdlib:ContainedInStructure",
"ifc2x3tc1-stdlib:OwnerHistory",
"ifc2x3tc1-stdlib:Representation",
"ifc2x3tc1-stdlib:ObjectPlacement",
],
}
topicId = client.ServiceInterface.download(
query=json.dumps(query),
roids=[revision_id],
serializerOid=serializer_id,
sync=False,
)
# while (state := client.NotificationRegistryInterface.getProgress(topicId=topicId).get('state')) != 'FINISHED':
# print(state)
# sleep(1.)
sleep(1.0)
content = (
bimserver.urlopen(f"{hostname}/download?token={client.token}&topicId={topicId}", data=b"").read().decode("ascii")
)
ifc_file = ifcopenshell.file.from_string(content)
print(ifc_file)
print({i.is_a() for i in ifc_file})
# {'IfcWall', 'IfcWallStandardCase'}
# {'IfcAxis2Placement3D', 'IfcPersonAndOrganization', 'IfcCurveStyleFontPattern', 'IfcSurfaceStyle', 'IfcExtrudedAreaSolid', 'IfcDirection', 'IfcCartesianPoint', 'IfcRelAggregates', 'IfcRelContainedInSpatialStructure', 'IfcMaterialLayer', 'IfcFillAreaStyle', 'IfcGeometricRepresentationSubContext', 'IfcRelAssociatesMaterial', 'IfcPolyLoop', 'IfcMaterial', 'IfcBooleanClippingResult', 'IfcOwnerHistory', 'IfcApplication', 'IfcDraughtingPreDefinedCurveFont', 'IfcDimensionalExponents', 'IfcShapeRepresentation', 'IfcMaterialLayerSet', 'IfcStyledItem', 'IfcAxis2Placement2D', 'IfcConversionBasedUnit', 'IfcGeometricRepresentationContext', 'IfcFaceBasedSurfaceModel', 'IfcRectangleProfileDef', 'IfcFillAreaStyleHatching', 'IfcBuildingStorey', 'IfcProductDefinitionShape', 'IfcColourRgb', 'IfcProject', 'IfcPerson', 'IfcMaterialLayerSetUsage', 'IfcSIUnit', 'IfcFaceOuterBound', 'IfcPlane', 'IfcOrganization', 'IfcConnectedFaceSet', 'IfcBuilding', 'IfcWallStandardCase', 'IfcLocalPlacement', 'IfcMeasureWithUnit', 'IfcCurveStyle', 'IfcArbitraryClosedProfileDef', 'IfcPolyline', 'IfcSurfaceStyleRendering', 'IfcCurveStyleFont', 'IfcMaterialDefinitionRepresentation', 'IfcPresentationStyleAssignment', 'IfcWall', 'IfcStyledRepresentation', 'IfcFace', 'IfcUnitAssignment', 'IfcPolygonalBoundedHalfSpace', 'IfcSite'}
query = {
"type": "IfcElement",
"includeAllSubTypes": True,
"inBoundingBox": {
"x": -10000,
"y": -10000,
"z": -10000,
"width": 20000,
"height": 20000,
"depth": 20000,
},
}
topicId = client.ServiceInterface.download(
query=json.dumps(query),
roids=[revision_id],
serializerOid=serializer_id,
sync=False,
)
while client.NotificationRegistryInterface.getProgress(topicId=topicId).get("state") != "FINISHED":
sleep(1.0)
content = (
bimserver.urlopen(f"{hostname}/download?token={client.token}&topicId={topicId}", data=b"").read().decode("ascii")
)
ifc_file = ifcopenshell.file.from_string(content)
print(ifc_file.to_string())
Metadata
Metadata
Assignees
Labels
No labels