IfcOpenShell / IfcOpenShell

Open source IFC library and geometry engine
GNU Lesser General Public License v3.0
1.87k stars 733 forks source link

Can .xml connect to .glTF? #1245

Closed HWAZWD closed 3 years ago

HWAZWD commented 3 years ago

I've got two files,one is .xml and the other is .glTF.Now I load the .gltf file with Three.js,I was wondering when clicking a part of the model,how can I get the corresponding information stored in the .xml file?If not,any suggestions? Thanks a lot!

aothms commented 3 years ago

The IDs are the same. Just IFC uses a base64 encoding mechanism. In python you have ifcopenshell.guid.compress() / expand(). There is also a Javascript implementation here https://github.com/AECgeeks/BIMsurfer2/blob/master/bimsurfer/src/Utils.js#L54

In general you might want to consider switching to https://github.com/AECgeeks/BIMsurfer2. It also uses threejs. But solves the issue of integrating with XML (and 2D SVG). You might also want to consider https://github.com/AECgeeks/ifc-pipeline which includes BIMsurfer2 and a Python based processing queue for the model conversion.

HWAZWD commented 3 years ago

@aothms Thanks a lot,that's working!

theRealSuperMario commented 3 years ago

Is there any way you can toggle if you want base64 encoding or not in the output file when running IfcConvert?

Me personally, I just want all the ids to be the same, regardless of the implementation details and output file formats.

Maybe that's just my personally taste, but I don't see a point in allowing this inconsistency in the first place, even if IFC is the format that does the weird thing. If the pipeline starts with IFC, the ids should just be kept in the same format throughout the pipeline.

What do you think?

aothms commented 3 years ago

@theRealSuperMario you can use the --use-element-guids option to retain the same IFC base64 encoding. Issue is that these are not valid XML identifiers due to character set and starting with a number. Hence the default naming.

theRealSuperMario commented 3 years ago

@aothms Thanks for the hint.

Just to recab:

aothms commented 3 years ago

The reasoning is that the glTF serializer is quite new. The previous approach to get glTF was through collada serializer and then collada2gltf. So I prefer these flows to be compatible.

I wrote a tiny script which just converts the guids back to base64, and it works fine

But isn't that the point? It doesn't matter much. It's just a preference of whether you choose consistency within the geometric output formats, or choose resemblance with IFC.

theRealSuperMario commented 3 years ago

I understand. That makes sense. I am just a hardcore consistency lover I suppose. Sorry for bothering.

aothms commented 3 years ago

No worries, if you see things to make consistent feel free to send PRs. Especially now that we just started the 0.7.0 branch there is definitely room for some backwards incompatible clean up :)