Esempio n. 1
0
    def Activated(self):
        from femtools import femutils
        overalboundbox = femutils.getBoundBoxOfAllDocumentShapes(
            FreeCAD.ActiveDocument)
        # print(overalboundbox)
        min_bb_length = (min(
            set([
                overalboundbox.XLength, overalboundbox.YLength,
                overalboundbox.ZLength
            ])))
        dbox = min_bb_length * 0.2

        aFace = femutils.getSelectedFace(FreeCADGui.Selection.getSelectionEx())
        if aFace:
            f_CoM = aFace.CenterOfMass
            f_uvCoM = aFace.Surface.parameter(
                f_CoM)  # u,v at CoM for normalAt calculation
            f_normal = aFace.normalAt(f_uvCoM[0], f_uvCoM[1])
        else:
            f_CoM = FreeCAD.Vector(0, 0, 0)
            f_normal = FreeCAD.Vector(0, 0, 1)

        from pivy import coin
        coin_normal_vector = coin.SbVec3f(-f_normal.x, -f_normal.y,
                                          -f_normal.z)
        coin_bound_box = coin.SbBox3f(f_CoM.x - dbox, f_CoM.y - dbox,
                                      f_CoM.z - dbox * 0.15, f_CoM.x + dbox,
                                      f_CoM.y + dbox, f_CoM.z + dbox * 0.15)
        clip_plane = coin.SoClipPlaneManip()
        clip_plane.setValue(coin_bound_box, coin_normal_vector, 1)
        FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().insertChild(
            clip_plane, 1)
    def Activated(self):
        try:
            clip_plane = coin.SoClipPlaneManip()
            clip_plane.setValue(coin.SbBox3f(
                4, 4, 4, 8, 8, 8), coin.SbVec3f(-1, -1, -1), 1)
            Gui.ActiveDocument.ActiveView.getSceneGraph().insertChild(clip_plane, 1)
            Gui.ActiveDocument.ActiveView.viewAxonometric()
            Gui.ActiveDocument.ActiveView.fitAll()

        except Exception as err:
            App.Console.PrintError("'View Inside objects' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)