You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As from_step(cls, filepath) raises a NotImplemented Error I was wondering which behavior is sought for this method ? As it could be quite a complex I/O, my take on it is fairly simple, relying on Paviot's Extend snippets, it gets the first valid surface and retrieve it as a NurbsSurface :
importsysimportloggingimportpathlibfromOCC.Core.GeomAbsimportGeomAbs_Plane, GeomAbs_BSplineSurfacefromOCC.Core.GeomConvertimportgeomconvert_SurfaceToBSplineSurfacefromOCC.Extend.DataExchangeimportread_step_filefromOCC.Extend.TopologyUtilsimportTopologyExplorerfromOCC.Core.BRepimportBRep_ToolfromOCC.Core.BRepAdaptorimportBRepAdaptor_SurfacefromOCC.Core.BRepBuilderAPIimportBRepBuilderAPI_NurbsConvertfromOCC.Core.TopoDSimporttopodsfromcompas_occ.geometryimportOCCNurbsSurfaceasNurbsSurfacedefread_bsplinesrf_from_stp_file(input_file):
shp=read_step_file(input_file)
t=TopologyExplorer(shp)
ift.number_of_faces() ==0:
raiseValueError(f"Input step file must contain at least one face to import")
elift.number_of_faces() >1:
logging.warning("Too much faces unpacked, retrieving the first valid one")
forfint.faces():
adasurf=BRepAdaptor_Surface(f, True)
surf_type=adasurf.GetType()
ifsurf_type==GeomAbs_Plane:
gp_pln=adasurf.Plane() # look for the properties of the plane, first get the related gp_Plnlocation=gp_pln.Location() # a point of the planenormal=gp_pln.Axis().Direction() # the plane normallogging.info(f"face is GeomAbs_Plane: {location.X(), location.Y(), location.Z()}, normal: {normal.X(), normal.Y(), normal.Z()}")
nurbs_converter=BRepBuilderAPI_NurbsConvert(f)
nurbs_converter.Perform(f)
nurbs_face=nurbs_converter.Shape()
h_geomsurface=BRep_Tool.Surface(topods.Face(nurbs_face))
h_bsurface=geomconvert_SurfaceToBSplineSurface(h_geomsurface)
returnh_bsurface# nbs = OCCNurbsSurface.from_occ(h_bsurface)elifsurf_type==GeomAbs_BSplineSurface:
nurbs_converter=BRepBuilderAPI_NurbsConvert(f)
nurbs_converter.Perform(f)
nurbs_face=nurbs_converter.Shape()
h_geomsurface=BRep_Tool.Surface(topods.Face(nurbs_face))
h_bsurface=geomconvert_SurfaceToBSplineSurface(h_geomsurface)
returnh_bsurface# nbs = OCCNurbsSurface.from_occ(h_bsurface)else:
raiseNotImplementedError("Face type is %s in GeomAbs enum"%str(surf_type))
# 0:GeomAbs_Plane, 1:GeomAbs_Cylinder, 2:GeomAbs_Cone, 3:GeomAbs_Sphere, 4:GeomAbs_Torus, 5:GeomAbs_BSplineSurface, 6:GeomAbs_SurfaceOfRevolution# 7:GeomAbs_SurfaceOfExtrusion, 8:GeomAbs_OffsetSurface, 9:GeomAbs_OtherSurface
If it can be of any use, I'd be glad to contribute 🚀
Best regards,
Antoine Gros
The text was updated successfully, but these errors were encountered:
Hey,
As
from_step(cls, filepath)
raises a NotImplemented Error I was wondering which behavior is sought for this method ? As it could be quite a complex I/O, my take on it is fairly simple, relying on Paviot's Extend snippets, it gets the first valid surface and retrieve it as a NurbsSurface :If it can be of any use, I'd be glad to contribute 🚀
Best regards,
Antoine Gros
The text was updated successfully, but these errors were encountered: