def setPreselection(self, doc, obj, sub): sel = FreeCADGui.Selection.getSelectionEx() v = FreeCADGui.ActiveDocument.ActiveView d = FreeCADGui.ActiveDocument so = FreeCAD.ActiveDocument.getObject(obj) if not hasattr(so, "Shape"): return faces = so.Shape.Faces typ = sub[0:4] if not typ == "Face": return idx = int(sub[4:]) face = faces[idx - 1] txt = "" occface = Part.__toPythonOCC__(face) #surf = occface.Surface() ts = _TopoDS_face(occface) face_adaptor = BRepAdaptor_Surface(ts) face_type = face_adaptor.GetType() surf_txt = self.getSurfType(face_type) txt = self.getSurfEqua(surf_txt, face_adaptor) #t = GeomAdaptor_Surface(TopoDS_Shape(occface)).GetType() #FreeCAD.Console.PrintMessage("%s\n" % (str(t))) #if (str(face.Surface) == "<Plane object>"): #txt = "Plane" #elif (str(face.Surface) == "<Cylinder object>"): #txt = "Cylinder" #elif (str(face.Surface) == "<Toriod object>"): #txt = "Torus" pnt = v.getPoint(v.getCursorPos()) #FreeCAD.Console.PrintMessage("X %f Y %f Z %f\n" % (pnt.x, pnt.y, pnt.z)) adoc = FreeCAD.ActiveDocument objlist = adoc.findObjects("App::Annotation", "SurfInfo") if (objlist): objlist[0].LabelText = txt objlist[0].Position = (pnt.x, pnt.y, pnt.z)
def identifySurf(self): occface = Part.__toPythonOCC__(self.__faceObj) ts = _TopoDS_face(occface) face_adaptor = BRepAdaptor_Surface(ts) face_type = face_adaptor.GetType() if (face_type == GeomAbs_Plane): self.__surfType = "Plane" elif (face_type == GeomAbs_Cylinder): self.__surfType = "Cylinder" elif (face_type == GeomAbs_Sphere): self.__surfType = "Sphere" elif (face_type == GeomAbs_Cone): self.__surfType = "Cone" elif (face_type == GeomAbs_Torus): self.__surfType = "Toroid" elif (face_type == GeomAbs_SurfaceOfRevolution): self.__surfType = "Revolution" else: self.__surfType = "Spline"