Macro Copy3DViewToClipboard: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
m (link to Gist cause inappropriate indentation)
Line 41: Line 41:


<!--T:10-->
<!--T:10-->
'''Macro_Copy3DViewToClipboard.FCMacro'''
Copy the macro to Gist [https://gist.github.com/mario52a/f5c3738f858f7b058897c6c235232cbe '''Macro_Copy3DViewToClipboard.FCMacro''' ]


</translate>
</translate>
{{Code|code=
# -*- coding: utf-8 -*-
import PySide
from PySide.QtGui import *
from PySide import QtGui ,QtCore
from PySide import QtOpenGL
#from gimpfu import *

<!--T:12-->
__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}}

Revision as of 20:19, 20 September 2016

File:Macro Copy3DViewToClipboard Macro Copy3DViewToClipboard

Description
Copy contents of 3DView to clipboard

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

Description

Macro will copy the contents of the 3D view to the clipboard

How To Use

  • Run once to activate macro (the macro is loaded resident into the memory of the PC).
  • Press G to grab the contents of the 3d view and copy them to the clipboard.
  • Press Q to quit.

PS: if you wild other format modify the values of the line number 33 ex:

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

to

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

Discussion

See forum-thread here.

Code

The icon for you toolbar

Copy the macro to Gist Macro_Copy3DViewToClipboard.FCMacro


Other languages: