Copy & Paste

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
wmayer
Founder
Posts: 20306
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Copy & Paste

Post by wmayer »

Hi everybody,

I want to announce that I have implemented a general copy&paste framework with the following features:
  • copy&paste works between several FreeCAD instances
  • copying objects of several documents is possible
  • paste works currently always on the active document. If no document is open (because you have closed it after copying) one gets created automatically
  • copy&paste stores/restores all properties of the selected objects and their view providers as well
  • copy a file inside your file manager (e.g. Explorer on Windows) and paste it into FreeCAD. If the file format is supported it gets loaded into the currently active document. If no document exists one gets created first.
In order to copy the objects they must be serialized in a certain form to transport the data to the clipboard. This is done by streaming the data into a format which is very similar to our FCStd format. If the amount of data doesn't exceed a certain amount of memory (10 MB at the moment) everything is kept in RAM, otherwise a file is created to save the data.

Copying the data could be an expensive operation for bigger datasets which could freeze the application for some time. Thus, I have also implemented a lightweight alternative to duplicate objects. I have named the command "Duplicate selection" to avoid any confusion with copy&paste. This command is supposed to create copies of the selected object (it's also possible to have objects selected from different documents) and add the copies into the active document. This method works only within one FreeCAD instance.

Cheers,
Werner
Post Reply