Retrieve the path of a saved document.

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Retrieve the path of a saved document.

Post by onekk »

Hello to all.

I know that is a strange requests, but I'm trying to do some experiment in automating this workflow:

https://github.com/Zolko-123/FreeCAD_Ex ... /README.md

It is somewhat related to:

https://forum.freecadweb.org/viewtopic.php?f=22&t=72011

Now I have to save the file and reopen it, so I do:

Code: Select all

doc1_fname = f"{DOC1_NAME}.FCStd"
doc1.FileName = doc1_fname
doc1.save()
FreeCAD.closeDocument(DOC1_NAME)
Now I have to retrieve the path where FC has saved the document.

I was expecting something like

Code: Select all

doc_path = doc1.save()
In other word that the function will return the path where FC has saved the document.

Anyone know an easy way to retrieve this thing.

What I know is that if you don't specify a path actually on Linux it save the file in the "user directory", I could do two things:
  1. Create e repository explicitly, using the path to prepend it to all filenames
  2. Trust that if I don't specify a path it is saved across different OS in the "user directory", but how to find what is across different OS
Is a strange request, and this is simply an exercise to gain some experience in Asm4 coding (if possible), but I think it will be an useful addition like the ability to retrieve the DocumentObject create with Part.show()

Code: Select all

obj = Part.show(solid, "solid_name")
Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply