Ho I can extract the area of face for a wall and the corners vertices (coordinates). Itired the following method but it is not working by OCC library :
To extract the area of each face of the wall, first you will need to explore the wall shape and find each face of the wall using TopExp_Explorer. Further you can use the extracted face to find the vertex on each face.
fromOCC.Core.TopExpimportTopExp_ExplorerfromOCC.Core.TopoDSimporttopodsfromOCC.Core.TopAbsimportTopAbs_FACE,TopAbs_VERTEXfromOCC.Core.BRepimportBRep_ToolfromOCC.Core.GPropimportGProp_GPropsfromOCC.Core.BRepGPropimportbrepgprop_SurfacePropertiesimportifcopenshellimportifcopenshell.geomsettings=ifcopenshell.geom.settings()settings.set(settings.USE_PYTHON_OPENCASCADE,True)file=ifcopenshell.open("Duplex_A_20110907_optimized.ifc")wall=file.by_type("IfcWall")[9]wall_brep_shape=ifcopenshell.geom.create_shape(settings,wall)# Create an explorer on wall shape and find all the face on this shapeexplore_face=TopExp_Explorer(wall_brep_shape.geometry,TopAbs_FACE)whileexplore_face.More():face=topods.Face(explore_face.Current())props=GProp_GProps()brepgprop_SurfaceProperties(face,props)# props.Mass() provides area of faceface_area=props.Mass()print(face,face_area)# Create an explorer on face and find all the vertexexplore_vertex=TopExp_Explorer(face,TopAbs_VERTEX)whileexplore_vertex.More():vertex=topods.Vertex(explore_vertex.Current())# Coordinate of vertex on facevertex_point=BRep_Tool().Pnt(vertex).Coord()print(vertex,vertex_point)explore_vertex.Next()explore_face.Next()
C:\Users\Malavan-PC\AppData\Local\Programs\Python\Python38-32\python.exe
Is not your Anaconda Python I assume. Did you properly setup anaconda and conda activate? Otherwise try running from the Anaconda Prompt.
I have re-installed the anaconda and use Anaconda python
Result:
C:\Users\Malavan-PC\anaconda3\python.exe
['C:\Users\Malavan-PC\anaconda3', 'C:\Users\Malavan-PC\anaconda3\lib\site-packages']
C:\Users\Malavan-PC\AppData\Roaming\Python\Python38\site-packages
PS C:\Users\Malavan-PC\OneDrive - York University\Coding>
I remored all version of pythons on my machine and just reinstall the Anacoda. It works now. Thanks all for help and supports
Last edit: Hamid Kiavarz 2020-12-02
Ho I can extract the area of face for a wall and the corners vertices (coordinates). Itired the following method but it is not working by OCC library :
ifcopenshell.geom.create_shape(...).geometry.verts
Thanks,
Hamid
Hi Hamid,
To extract the area of each face of the wall, first you will need to explore the wall shape and find each face of the wall using TopExp_Explorer. Further you can use the extracted face to find the vertex on each face.
For more details please check:
1. OCC.Core.TopExp.TopExp_Explorer
2. OCC.Core.TopoDS.topods