Foreword: I am aware that this can be done using pure FreeCAD commands but I need to have it working using pythonocc first.
My question in short: how do you access a knot sequence and how do you update it?
My code so far (which is an adaptation of one script from PyGeM script):
Code: Select all
from OCC.STEPControl import STEPControl_Reader
reader = STEPControl_Reader()
fileLocation = "pipe.step"
return_reader = reader.ReadFile(fileLocation)
return_transfer = reader.TransferRoots()
shape = reader.OneShape()
# Looping through the faces
facesExplorer = TopExp_Explorer(shape, TopAbs_FACE):
face = topods_Face(faces_explorer.Current())
nurbs_converter = BRepBuilderAPI_NurbsConvert(face)
nurbs_converter.Perform(face)
nurbs_face = nurbs_converter.Shape()
face_aux = topods_Face(nurbs_face)
brep_face = BRep_Tool.Surface(topods_Face(nurbs_face))
bspline_face = geomconvert_SurfaceToBSplineSurface(brep_face)
occ_face = bspline_face.GetObject()
print("No Uknots", occ_face.NbUKnots())
.....
.....
n_faces += 1
faces_explorer.Next()
Specific question: Now I have surface which has 2 knots along both U and V directions. What I'd like to do is to increase that number to 10 in both U and V directions and set their values (I know them).
Proposed action: Using python dir(occ_face) I can see all the methods available on the occ_face object to access the knots info. I am sure I can get the sequence via UKnotSequence () and then update their value via SetUKnot() or SetUKnots(), but reading the online API is not helping me, meaning I am not sure on the syntax.
Thanks