App::PropertyFile for getting save file

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
ebrahim raeyat
Posts: 619
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

App::PropertyFile for getting save file

Post by ebrahim raeyat »

App::PropertyFile is for getting a file that exists. Is there a property for getting save file? also applying filter to extension of files?

I think setFilter is for filtering extension, but don't know how can I use it. Thanks.

https://freecad.github.io/SourceDoc/d9/ ... yFile.html
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: App::PropertyFile for getting save file

Post by onekk »

ebrahim raeyat wrote: Sat Jul 30, 2022 10:16 pm App::PropertyFile is for getting a file that exists. Is there a property for getting save file? also applying filter to extension of files?

In what sense, "save file"

If you have not saved a file, FC could have created one "Unamed" and when you try to save FC will ask you for a "proper name" to assign it.

If you have saved it is in the "document tree" as a "file object".

Not knowing much more if there are some settings to activate autosaving files automatically, or making backup files.

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/
User avatar
ebrahim raeyat
Posts: 619
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: App::PropertyFile for getting save file

Post by ebrahim raeyat »

onekk wrote: Mon Aug 01, 2022 3:40 pm
In what sense, "save file"

If you have not saved a file, FC could have created one "Unamed" and when you try to save FC will ask you for a "proper name" to assign it.

If you have saved it is in the "document tree" as a "file object".

Not knowing much more if there are some settings to activate autosaving files automatically, or making backup files.

Regards

Carlo D.
Thanks. I mean Property for the object like this:

Code: Select all


import FreeCAD


class SafeF2k:
    def __init__(self, obj):
        self.set_properties(obj)

    def set_properties(self, obj):
        self.Type = "f2k"
        obj.Proxy = self

        if not hasattr(obj, "input"):
            obj.addProperty(
                "App::PropertyFile",
                "input",
                "Safe",
                )
        if not hasattr(obj, "output"):
            obj.addProperty(
                "App::PropertyFile",
                "output",
                "Safe",
                )
when I click on input it open a dialog for getting a file to open. For output I want a Save dialog.

complete link: https://github.com/ebrahimraeyat/OSAFE/ ... _object.py
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: App::PropertyFile for getting save file

Post by onekk »

I have to check but from what i know filedialog could be use to save files, there is a flag during invocation.

But now I'm not at my computer and I can't get more information.

Plus I don't know if the "App::PropertyFile" with "output" will trigger a filedialog already configured to save files.

Another think is that FileDialog if I remeber well could be set to use the standard QFileDialog and the one supplid from the OS.

Probably I'm not to being of big help, sorry!

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/
User avatar
ebrahim raeyat
Posts: 619
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: App::PropertyFile for getting save file

Post by ebrahim raeyat »

Thanks @onekk .
I still did not know how can I do that. any Idea?
Post Reply