Macro Copia la vista 3D negli appunti

From FreeCAD Documentation
Jump to navigation Jump to search
This page is a translated version of the page Macro Copy3DViewToClipboard and the translation is 92% complete.
Outdated translations are marked like this.
Other languages:
English • ‎français • ‎italiano

Macro Copy3DViewToClipboard.png Copia la vista 3D negli appunti

Descrizione
Copia il contenuto della vista 3D negli appunti

Versione macro: 00.01
Ultima modifica: 2016-09-14
Versione FreeCAD: <=0.17
Download: ToolBar Icon
Autore
Mario52
Download
ToolBar Icon
Link
Versione macro
00.01
Data ultima modifica
2016-09-14
Versioni di FreeCAD
<=0.17
Scorciatoia
G, Q
Vedere anche
Macro Snip Snip.png

Descrizione

La macro copia il contenuto della vista 3D negli appunti in immagine bitmap (BMP). La copia dentro Gimp no è possibile Gimp utilizza il suo metodo.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager.


# 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")
<class="rawcodeurl"><a href="https://gist.githubusercontent.com/mario52a/f5c3738f858f7b058897c6c235232cbe/raw/a10bc3b8789badc1e405541d4697d7286d9f0fd3/Macro_Copy3DViewToClipboard.FCMacro">raw code</a>


Uso

  • Eseguirla una volta per attivare macro (la macro viene caricata e rimane residente nella memoria del PC).
  • Premere G per catturare il contenuto della vista 3D e copiarlo negli appunti.
  • Premere Q pr uscire.

Per avere un formato diverso modificare i valori nella riga 33 ad esempio:

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

in

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

Discussione

Vedere la discussione nel forum.

Codice

L'icona per la barra degli strumenti Macro Copy3DViewToClipboard.png


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)