MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / _execute

Method _execute

src/bonsai/scripts/obj2ifc-meshlab.py:49–97  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47 self._execute()
48
49 def _execute(self):
50 mesh_set = pymeshlab.MeshSet()
51 mesh_set.load_new_mesh(self.path)
52
53 self.format = None
54 if self.path.lower().endswith(".obj"):
55 self.format = "obj"
56
57 for mesh in mesh_set:
58 faces = mesh.face_matrix()
59 vertices = mesh.vertex_matrix()
60
61 ifc_faces = np.zeros([len(faces)], dtype=object)
62 for i, face in enumerate(faces):
63 ifc_faces[i] = self.file.createIfcFace(
64 [
65 self.file.createIfcFaceOuterBound(
66 self.file.createIfcPolyLoop(
67 [
68 self.file.createIfcCartesianPoint(self.get_coordinates(vertices[index].tolist()))
69 for index in face
70 ]
71 ),
72 True,
73 )
74 ]
75 )
76 representation = self.file.createIfcProductDefinitionShape(
77 None,
78 None,
79 [
80 self.file.createIfcShapeRepresentation(
81 self.context,
82 "Body",
83 "Brep",
84 [self.file.createIfcFacetedBrep(self.file.createIfcClosedShell(ifc_faces.tolist()))],
85 )
86 ],
87 )
88 product = self.file.create_entity(
89 "IfcBuildingElementProxy",
90 GlobalId=ifcopenshell.guid.new(),
91 Name=mesh.label() or self.basename,
92 Representation=representation,
93 )
94 ifcopenshell.api.spatial.assign_container(self.file, products=[product], relating_structure=self.storey)
95 product.ObjectPlacement = self.placement
96
97 self.file.write(self.outfile)
98
99 def get_coordinates(self, coordinates):
100 if self.format == "obj":

Callers 1

executeMethod · 0.95

Calls 6

get_coordinatesMethod · 0.95
lowerMethod · 0.80
newMethod · 0.80
labelMethod · 0.80
create_entityMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected