Macro Copy3DViewToClipboard/fr: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(Updating to match new version of source page)
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
{{Macro/fr|Icon=Macro_Copy3DViewToClipboard|Name/fr=Macro Copy3DViewToClipboard|Description=Copie le contenu de la vue 3DView dans la mémoire|Author=Mario52|Version=00.01|Date=2016-09-14}}
{{Macro/fr
|Name=Macro Copy3DViewToClipboard
|Icon=Macro_Copy3DViewToClipboard.png
|Description=Cette macro copie le contenu de la vue 3D redimensionnée en 640 x 480 pixels dans la mémoire en image bitmap (BMP). La copie dans Gimp n'est pas possible Gimp utilise sa propre méthode pour la fonction copier.
|Author=Mario52
|Version=00.01
|Date=2016-09-14
|FCVersion= <=0.17
|Download=[https://www.freecadweb.org/wiki/images/8/84/Macro_Copy3DViewToClipboard.png ToolBar Icon]
|Shortcut=G Q
|SeeAlso=[[Macro_Snip/fr|Macro Snip]] [[Image:Snip.png|24px]]<br/>[[Macro Screen Wiki/fr|Macro Screen Wiki]] [[Image:Macro_Screen_Wiki.png|24px]]
}}


==Description==
==Description==


Cette macro copie le contenu de la vue 3D redimensionnée en 640 x 480 pixels dans la mémoire.
Cette macro copie le contenu de la vue 3D redimensionnée en 640 x 480 pixels dans la mémoire en image bitmap (BMP). La copie dans Gimp n'est pas possible Gimp utilise sa propre méthode pour la fonction copier.


{{Codeextralink|https://gist.githubusercontent.com/mario52a/f5c3738f858f7b058897c6c235232cbe/raw/a10bc3b8789badc1e405541d4697d7286d9f0fd3/Macro_Copy3DViewToClipboard.FCMacro}}
{{Codeextralink|https://gist.githubusercontent.com/mario52a/f5c3738f858f7b058897c6c235232cbe/raw/a10bc3b8789badc1e405541d4697d7286d9f0fd3/Macro_Copy3DViewToClipboard.FCMacro}}
Line 14: Line 26:


PS: Si vous voulez définir une autre résolution d'image, modifiez les valeurs de la ligne numéro 33 ex:
PS: Si vous voulez définir une autre résolution d'image, modifiez les valeurs de la ligne numéro 33 ex:

{{Code|code=
glw.resize(640, 480) # reduce the SubWindow
line 33 : '''''glw.resize(640, 480) # reduce the SubWindow'''''

}}
par
par

{{Code|code=
glw.resize(800, 600) # reduce the SubWindow
Line 33 : '''''glw.resize(800, 600) # reduce the SubWindow'''''
}}


==Discussion==
==Discussion==
Line 30: Line 41:
L'icône pour votre barre d'outil [[File:Macro_Copy3DViewToClipboard.png]]
L'icône pour votre barre d'outil [[File:Macro_Copy3DViewToClipboard.png]]


téléchargez la macro sur Gist [https://gist.github.com/mario52a/f5c3738f858f7b058897c6c235232cbe '''Macro_Copy3DViewToClipboard.FCMacro''' ]


'''Macro_Copy3DViewToClipboard.FCMacro'''


{{MacroCode|code=
# -*- 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)

}}
{{clear}}
{{clear}}
<languages/>

Revision as of 09:57, 23 May 2020

Other languages:

Macro Copy3DViewToClipboard

Description
Cette macro copie le contenu de la vue 3D redimensionnée en 640 x 480 pixels dans la mémoire en image bitmap (BMP). La copie dans Gimp n'est pas possible Gimp utilise sa propre méthode pour la fonction copier.

Version macro : 00.01
Date dernière modification : 2016-09-14
Version FreeCAD : <=0.17
Téléchargement : ToolBar Icon
Auteur: Mario52
Auteur
Mario52
Téléchargement
ToolBar Icon
Liens
Version Macro
00.01
Dernière modification
2016-09-14
Version(s) FreeCAD
<=0.17
Raccourci clavier
G Q
Voir aussi
Macro Snip
Macro Screen Wiki

Description

Cette macro copie le contenu de la vue 3D redimensionnée en 640 x 480 pixels dans la mémoire en image bitmap (BMP). La copie dans Gimp n'est pas possible Gimp utilise sa propre méthode pour la fonction copier.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "https://gist.githubusercontent.com/mario52a/f5c3738f858f7b058897c6c235232cbe/raw/a10bc3b8789badc1e405541d4697d7286d9f0fd3/Macro_Copy3DViewToClipboard.FCMacro" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("https://gist.githubusercontent.com/mario52a/f5c3738f858f7b058897c6c235232cbe/raw/a10bc3b8789badc1e405541d4697d7286d9f0fd3/Macro_Copy3DViewToClipboard.FCMacro")


Utilisation

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

PS: Si vous voulez définir une autre résolution d'image, modifiez les valeurs de la ligne numéro 33 ex:

line 33 : glw.resize(640, 480) # reduce the SubWindow

par

Line 33 : glw.resize(800, 600) # reduce the SubWindow

Discussion

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

Script

L'icône pour votre barre d'outil


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)