Is it possible to copy all the content from grasshopper file that’s currently open to another grasshopper file using scripting components?
Yes, selecting all relevant components, copying them, and pasting them into a new file works!
You could ‘File | Save Document As…’ a different file name?
I mean - copy all the components programmatically.
Let’s say we have some switch on canvas that would copy all the components (or some part) to another grasshopper document, when turned on.
I suspect that it’s not possible, but maybe there is some ways…
Save Document As in my case will not work. I’m using Grasshopper script to generate geometry in other 3D software. Saving document with a new name still makes Grasshopper to target same 3D objects. So each new document will replace old geometry when opened. Instead I need new geometry for each file.
Manually copying components of course is a solution. However I need a lot of those files, so looking for a way to automate.
Which is the
other 3d software are you using? Does it have its own set of grasshopper nodes with element binding (such as Tekla)? It would be worth including this in your question since this sounds like it might the root of your workflow problem
Hi. It is Tekla.
As far as I can tell, The Tekla live link grasshopper nodes store a reference to the elements they have created. This is used to manage update, delete and create in subsequent runs. I’m guessing you are trying to get around this behaviour, because it doesn’t give you adequate control. Dynamo revit has a similar black box approach to updates, which works for testing small scripts, but is unsuitable for project reality. The Tekla API can be called from ghpython nodes. I’ve used this in a limited way in the past, and from memory it was pretty straightforward. I can send an example when I’m next at a PC. It might be too worthwhile asking about this problem on the Tekla forums https://forum.tekla.com/
tekla api.gh (40.8 KB)
see this example. It only creates straight beams, but it should make a start for you. Please note it doesn’t manage tekla model objects for you. every time you click the
commit button it will create new objects i the open tekla model.
You may also need to change the file paths in the python components to match the version you are using
(upload://5EKK9I8qUVijrCbH2C5T0J0p6d5.gh) (40.8 KB)