Macro Copy3DViewToClipboard/fr: Difference between revisions

From FreeCAD Documentation
(Created page with "La discussion sur le forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=16731 Copy contents of 3D view to clipboard].")
(Created page with "==Script==")
Line 15: Line 15:
La discussion sur le forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=16731 Copy contents of 3D view to clipboard].
La discussion sur le forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=16731 Copy contents of 3D view to clipboard].


==Code==
==Script==


The icon for you toolbar [[File:Macro_Copy3DViewToClipboard.png]]
The icon for you toolbar [[File:Macro_Copy3DViewToClipboard.png]]

Revision as of 19:20, 14 September 2016

File:Macro Copy3DViewToClipboard Macro Copy3DViewToClipboard

Description
Copie le contenu de la vue 3DView dans la mémoire

Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Description

Cette macro copie le contenu de la vue 3D redimensionnée en 640 x 480 pixels dans la mémoire.

Utilisation

  • Lancez la macro.
  • Pressez la touche G pour copier le contenu de la vue 3D.
  • Pressez la touche Q pour quitter la macro.

Discussion

La discussion sur le forum Copy contents of 3D view to clipboard.

Script

The icon for you toolbar

Macro_Copy3DViewToClipboard.FCMacro

# -*- coding: utf-8 -*-
import PySide
from PySide.QtGui import *
from PySide import QtGui ,QtCore
from PySide import QtOpenGL
#from gimpfu import *

__title__   = "Macro_Copy3DViewToClipboard"
__author__  = "Mario52"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.01"
__date__    = "14/09/2016"
           
class ViewObserver:
    print "run FCGrab .."
 
    def logPosition(self, info):
        import tempfile
        import os
        from PySide import QtGui
 
        pos = info["Key"]
        if pos.upper() == "G":
            pos = ""
           
            mw=Gui.getMainWindow()
            gl=mw.findChildren(QtOpenGL.QGLWidget)
            glw=gl[0] # just use the first element
 
            originalsize = glw.size()                               # originalsize SubWindow
            print "originalsize : ",originalsize.width(),", ", originalsize.height()
 
            glw.resize(640, 480)                                    # reduce the SubWindow
            glw.show()
            Gui.SendMsgToActiveView("ViewFit")
            print "resize in : ",glw.frameGeometry().width()," ",glw.frameGeometry().height()
 
            i=glw.grabFrameBuffer()
            cb=QtGui.qApp.clipboard()
            cb.setImage(i)
            glw.resize(originalsize.width(), originalsize.height()) # restore originalsize SubWindow
            print "Grab"
 
        if (pos.upper() == "Q"):
            v.removeEventCallback("SoKeyboardEvent",c)
            print "End FCGrab"
 
 
v=Gui.activeDocument().activeView()
o = ViewObserver()
c = v.addEventCallback("SoKeyboardEvent",o.logPosition)


Other languages: