OpenDocument twice

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jacknotreally
Posts: 75
Joined: Mon Dec 14, 2009 9:49 am

OpenDocument twice

Post by jacknotreally »

maybe this is very stupid.
I am not able to open the same file twice inside FreeCAD with App.OpenDocument().
The second one should behave like a separate file.
Creating a new document and import the "second" file from disk would also be ok.

Or do i have to make a workaround and have to copy of the file on disk.

Cheers
Jack - not really
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: OpenDocument twice

Post by wmayer »

An easy way is to create an empty document and then go to File > Merge projects.
jacknotreally
Posts: 75
Joined: Mon Dec 14, 2009 9:49 am

Re: OpenDocument twice

Post by jacknotreally »

More detailed:

Im using FreeCAD without GUI and having a drawing that consists on several FreeCAD documents.
Each FreeCAD document is imagined as an "assembly" inside my drawing.
So its is very easy to handle these "assemblies", because they are still separate FreeCAD documents.
The user is able to open a FreeCad file as a document (assembly) and to change some parts.
If he opens the document a second time (as an additional "assembly") this should be the latest file version,
not the one being loaded before and may be changed.

Cheers
Jack - not really
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: OpenDocument twice

Post by wmayer »

OK, you can achieve this with a little trick. But be careful it's up to you to not override the file with another document.

Code: Select all

App.openDocument("C:/project.FCStd")
d=App.newDocument()
d.FileName="C:/project.FCStd"
d.restore()
jacknotreally
Posts: 75
Joined: Mon Dec 14, 2009 9:49 am

Re: OpenDocument twice

Post by jacknotreally »

Hi Werner,

nice trick!

Thanks
Jack - not really
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: OpenDocument twice

Post by jriegel »

What you probably want to do is planed for the Assembly workbench. Its a document link object.
You have one document with links to other (open or not) documents. There you can link the same document twice with different
positions. Thats the classical way Catia does it.

It makes no sense in the long run to have two documents in memory with the same data....
Stop whining - start coding!
jack-not-really
Posts: 14
Joined: Fri Nov 15, 2013 5:30 pm

Re: OpenDocument twice => FreeCAD 0.14

Post by jack-not-really »

In FreeCAD 0.14 Doucment.FileName is read only.
Is there another way to open a Document twice?

Thanks
Jack-not-really
wmayer wrote:OK, you can achieve this with a little trick. But be careful it's up to you to not override the file with another document.

Code: Select all

App.openDocument("C:/project.FCStd")
d=App.newDocument()
d.FileName="C:/project.FCStd"
d.restore()
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: OpenDocument twice

Post by wmayer »

No, not at the moment. Maybe in the restore() method we can allow an optional string parameter to make this working again.
However, it must not collide with the points listed here: viewtopic.php?f=8&t=4000&p=31509&sid=28 ... 7c8#p31509
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: OpenDocument twice

Post by NormandC »

Please notice that we have a new forum section dedicated to help with python scripting. Accordingly, I moved this topic here from the "Help about using FreeCAD" forum, which is about using FreeCAD's GUI.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: OpenDocument twice

Post by wmayer »

There is now a method load() in the Python Document class where you can open a project in another document instance.
Post Reply