Code: Select all
OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15379 (Git)
Build type: Release
Branch: master
Hash: 3290c36d28551875f02333c2e01af80e38b8ad02
Python version: 2.7.15rc1
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
How to do Select All from Python is documented in https://www.freecadweb.org/wiki/Code_sn ... e_document (see also Select all visible objects by GUI tool - FreeCAD Forum, selection all without mouse - FreeCAD Forum):
Code: Select all
import FreeCAD
for obj in FreeCAD.ActiveDocument.Objects:
Gui.Selection.addSelection(obj) # select the object
For instance, this works in FreeCAD Python console:
Code: Select all
Gui.SendMsgToActiveView("ViewFit")
Code: Select all
Gui.SendMsgToActiveView("Copy")
Gui.SendMsgToActiveView("Cut")
Gui.SendMsgToActiveView("Paste")
Code: Select all
Unknown view command: Copy
Unknown view command: Cut
Unknown view command: Paste
Code: Select all
bool done = getGuiApplication()->sendMsgToActiveView("Copy");
Code: Select all
bool EditorView::onMsg(const char* pMsg,const char** /*ppReturn*/)
{
if (strcmp(pMsg,"Save")==0){
saveFile();
return true;
} else if (strcmp(pMsg,"SaveAs")==0){
saveAs();
return true;
} else if (strcmp(pMsg,"Cut")==0){
cut();
return true;
} else if (strcmp(pMsg,"Copy")==0){
copy();
return true;
} else if (strcmp(pMsg,"Paste")==0){
paste();
return true;
} else if (strcmp(pMsg,"Undo")==0){
undo();
return true;
} else if (strcmp(pMsg,"Redo")==0){
redo();
return true;
} else if (strcmp(pMsg,"ViewFit")==0){
// just ignore this
return true;
}
return false;
}
Code: Select all
{"SendMsgToActiveView", (PyCFunction) Application::sSendActiveView, METH_VARARGS,
"deprecated -- use class View"},
Code: Select all
{"activeView", (PyCFunction)Application::sActiveView, METH_VARARGS,
"activeView() -> object or None\n\n"
"Return the active view of the active document or None if no one exists"},
So, is there any kind of API, that supports calling Cut/Copy/Paste as in the GUI of FreeCAD?