Wed, 04/30/2025 - 09:11
Forums: 
I use pythonocc to load a STEP file, and then I want to extract geometry info of its every surface.
My STEP file is a simple pipe(pipe.png)It have 6 faces: the pipe has 2 cylindrical outer surfaces, 2 cylindrical inner surfaces, and the top and bottom annular planar surfaces, totaling 6 surfaces.
However, when I printed bspline_surface.Bounds(), the top and bottom surfaces were identified as square planes, not annular ones. I want to know how to accurately extract the geometric information of each surface's shape and range.
from __future__ import print_function
import numpy as np
import random
import os
import os.path
import sys
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB
from OCC.Display.SimpleGui import init_display
from OCC.Extend.TopologyUtils import TopologyExplorer
from OCC.Extend.DataExchange import read_step_file
from OCC.Core.BRep import BRep_Tool
from OCC.Core.gp import gp_Pnt
from OCC.Core.Geom import Geom_Plane, Geom_CylindricalSurface
from OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.IFSelect import IFSelect_RetDone
from OCC.Core.TopAbs import TopAbs_FACE
from OCC.Core.TopExp import TopExp_Explorer
from OCC.Core.TopoDS import TopoDS_Face, topods
from OCC.Core.GeomConvert import geomconvert
from OCC.Core.GProp import GProp_GProps
from OCC.Core.BRepGProp import BRepGProp_Face, brepgprop
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_NurbsConvert
from OCC.Core.BRepLib import BRepLib_FindSurface
def read_step(filepath):
    step_reader = STEPControl_Reader()
    IFstatus = step_reader.ReadFile(filepath)
    if(IFSelect_RetDone != IFstatus):
        raise Exception("fail")
    else:
        print("success")
    step_reader.TransferRoot()
    shape = step_reader.Shape()
    explorer = TopExp_Explorer(shape, TopAbs_FACE)
    while explorer.More():
        face = topods.Face( explorer.Current() )
        nurbs_converter  = BRepBuilderAPI_NurbsConvert(face)
        geom_surface = BRepLib_FindSurface(nurbs_converter.Shape()).Surface()
        bspline_surface = geomconvert.SurfaceToBSplineSurface(geom_surface)
        print(bspline_surface.Bounds(), geom_surface.Bounds())
        explorer.Next()
if __name__ == "__main__":
    filepath = "C:\\myproject\\lighttools\\NO1.STEP"
    read_step(filepath)
Attachments: 
        
Sun, 05/04/2025 - 11:05
There is no such a thing like an 'annular surface' in B-Rep - there is a usual plane bounded by circular edges. You need to start from learning what is B-Rep (boundary representation) and how it is implemented in OCCT.
Training materials might be a good point to start with (and in particular 'Topology' training). If you are already aware of it, you need to specify your question more accurately.