# Create a NURBS Brep: import pickle def loadPickle(filePath): with open(filePath, 'rb') as p_file: data = pickle.load(p_file) return data edgeStartEndLists = loadPickle(r"E:\ifcFiles\pickle\edgeStartEnd.pkl") edgeDegreeLists = loadPickle(r"E:\ifcFiles\pickle\edgeDegreeLists.pkl") edgeKnotsLists = loadPickle(r"E:\ifcFiles\pickle\edgeKnotsListsPath.pkl") edgeKnotMultLists = loadPickle(r"E:\ifcFiles\pickle\edgeKnotMultListsPath.pkl") edgePointsLists = loadPickle(r"E:\ifcFiles\pickle\edgePointsLists.pkl") faceDegreeULists = loadPickle(r"E:\ifcFiles\pickle\faceDegreeULists.pkl") faceDegreeVLists = loadPickle(r"E:\ifcFiles\pickle\faceDegreeVLists.pkl") faceKnotsULists = loadPickle(r"E:\ifcFiles\pickle\faceKnotsULists.pkl") faceKnotsVLists = loadPickle(r"E:\ifcFiles\pickle\faceKnotsVLists.pkl") faceKnotMultULists = loadPickle(r"E:\ifcFiles\pickle\faceKnotMultULists.pkl") faceKnotMultVLists = loadPickle(r"E:\ifcFiles\pickle\faceKnotMultVLists.pkl") facePointsLists = loadPickle(r"E:\ifcFiles\pickle\facePointsLists.pkl") bSurfs = []; bEdges = []; for faceInd in range(len(faceDegreeULists)): attributes = {} attributes["UDegree"] = faceDegreeULists[faceInd] attributes["VDegree"] = faceDegreeVLists[faceInd] attributes["ControlPointsList"] = [[ifc_file.createIfcCartesianPoint(point) for point in points] for points in facePointsLists[faceInd]] attributes["UMultiplicities"] = faceKnotMultULists[faceInd] attributes["VMultiplicities"] = faceKnotMultVLists[faceInd] attributes["UKnots"] = faceKnotsULists[faceInd] attributes["VKnots"] = faceKnotsVLists[faceInd] bSurf = ifc_file.create_entity("IfcBSplineSurfaceWithKnots", **attributes) bSurfs.append(bSurf) tempEdges = [] for edgeInd in range(len(edgePointsLists[faceInd])): attributes = {} attributes["ControlPointsList"] = [ifc_file.createIfcCartesianPoint(pnt) for pnt in edgePointsLists[faceInd][edgeInd]] attributes["Knots"] = edgeKnotsLists[faceInd][edgeInd] attributes["KnotMultiplicities"] = edgeKnotMultLists[faceInd][edgeInd] attributes["Degree"] = edgeDegreeLists[faceInd][edgeInd] bEdge = ifc_file.create_entity("IfcBSplineCurveWithKnots", **attributes) tempEdges.append(bEdge) startPoint ,endPoint = edgeStartEndLists[faceInd][edgeInd] bEdges.append(tempEdges) advancedFaces = [] for surfInd,surf in enumerate(bSurfs): orientedEdges = [] for edgeInd,edge in enumerate(bEdges[surfInd]): startPoint, endPoint = edgeStartEndLists[surfInd][edgeInd] edgeEnd = ifc_file.create_entity("IfcVertexPoint", VertexGeometry=ifc_file.create_entity("IfcCartesianPoint", endPoint)) edgeStart = ifc_file.create_entity("IfcVertexPoint", VertexGeometry=ifc_file.create_entity("IfcCartesianPoint", startPoint)) edgeCurve = ifc_file.create_entity("IfcEdgeCurve", EdgeStart=edgeStart, EdgeEnd=edgeEnd, EdgeGeometry=edge) orientedEdge = ifc_file.create_entity("IfcOrientedEdge", EdgeElement=edgeCurve, Orientation=True) orientedEdges.append(orientedEdge) edgeLoop = ifc_file.create_entity("IfcEdgeLoop", EdgeList=orientedEdges) faceOuterBound = ifc_file.create_entity("IfcFaceOuterBound", Bound=edgeLoop, Orientation=True) advancedFace = ifc_file.create_entity("IfcAdvancedFace", Bounds=(faceOuterBound,), FaceSurface=surf, SameSense=True) advancedFaces.append(advancedFace) closedShell = ifc_file.create_entity("IfcClosedShell", CfsFaces=advancedFaces) advancedBrep = ifc_file.create_entity("IfcAdvancedBrep", Outer=closedShell) # Assign the advanced brep representation to an instanced entity: wall = ifcopenshell.api.run("root.create_entity", ifc_file, ifc_class="IfcWall") shapeRep = ifc_file.createIfcShapeRepresentation(ContextOfItems=context, RepresentationIdentifier='Body', RepresentationType='AdvancedBrep', Items=[advancedBrep]) ifcopenshell.api.run("geometry.assign_representation", ifc_file, product=wall, representation=shapeRep) containment = ifcopenshell.api.run("spatial.assign_container", ifc_file, product=wall, relating_structure=storey) wall.ObjectPlacement = create_ifclocalplacement(ifc_file, point=O, dir1=Z, dir2=X, relative_to=None)